Daemon keeps running

Archived topics about LMDE 1
Forum rules
Level 1
Level 1
Posts: 1
Joined: Mon May 05, 2014 9:40 am

Daemon keeps running

Postby dennisj » Mon May 05, 2014 11:37 am


I have been pulling my hair out on this for days now. I have a daemon which is started via the user's startup in MATE, its purpose is to tail a file and execute a command any time a new entry appears (to email PDF files as they are created). The problem is that the daemon doesn't stop when the user has logged off. When they log back on, it starts another instance of it. I have corrected it from running multiple instances (by having the daemon check for the tail process as it starts and exit it it exists), but I need the daemon to stop when the user logs off. This server uses X2Go for remote access and users may have more than one active session. Therefore it's important that only the process started in that session is ended, if it exists. I have tried using the x2go_logoff script to accomplish this using the following -

PIDS=`ps | grep tai[l]`
if [ -z "$PIDS" ]; then
kill `ps | grep stsfaxliste[n] | awk '{print $1}'`
kill `ps | grep tai[l] | awk '{print $1}'`

-- but it doesn't work. It seems the MATE logoff scripts run as root and not in the user's session, so they are of no help either.

User avatar
Level 3
Level 3
Posts: 107
Joined: Sun Mar 30, 2014 12:38 am
Location: Colorado, USA

Re: Daemon keeps running

Postby xerion567 » Tue May 06, 2014 1:54 am

Hmm, have you tried adding --user $LOGNAME to your ps calls?
All work and no play makes Linux a dull OS,
All work and no play makes Linux a dull OS,
All work and no play makes Linux...viewtopic.php?f=58&t=164690

Return to “Archive”