Daemon keeps running

Archived topics about LMDE 1 and LMDE 2
Locked
dennisj

Daemon keeps running

Post by dennisj »

All,

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}'`
fi

-- 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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
xerion567

Re: Daemon keeps running

Post by xerion567 »

Hmm, have you tried adding --user $LOGNAME to your ps calls?
Locked

Return to “LMDE Archive”