I need to run some background processes that live as long as I am logged in with a certain user.
Does there exist something like a per-user daemon? I know only of global daemons that live from computer startup 'till shutdown (or manual startup/kill).
for now I made a script that checks if the process already exists and creates the process if it doesn't. This script is then run with the nohup
command from my .profile
. This way the process launches on startup, and is only launched once (even with multiple rxvt
terms coming and going). Yet, it never gets killed after I log (which isn't a disaster but it is cleaner to also terminate the process).
Best Answer
systemd allows users to run their own systemd instances to manage private daemons.
If you already have systemd installed, all you have to do is launch
systemd --user
and manage your services by runningsystemctl --user
. User services will be searched for in~/.config/systemd/user
.By default systemd will kill user services on logout (as you requested). This behavior can be altered by enabling lingering for a user with the
loginctl --enable-linger $USER
command.Mor information can be found on the ArchWiki page.