Adrián Antúnez asked:
I’m looking for a standard way or best practice to keep a daemon started by an
init.d shell script alive.
Or even better, is there a way to keep it alive directly from
Specifically, I have a daemon called dtnd with and infinite loop that looks for unexpected ended process, if there are any, the daemon wake up them again. Also, I use the start-stop-daemon tool in order to let the precess by run from a given system user.
I want to run this dtnd daemon from startup. In order to achieve this behavior I created a init.d script that “wraps” the dtnd file using start, stop and status commands.
I have 2 questions that I will like to solve:
Is there a way to achieve keeping alive some process from init.d shell script. Is an standard/best way practice?
It’s recommended to keep a process alive with infinite loop? I guess it’s better to use some command like
respawnto achieve that. It’s correct?
I know about the existance of the
respawn command. I think that’s what I need but I don’t understand the workflow between
/etc/init. Can anyone help me?
Note that I don’t have inittab neither upstart (I’m only allowed to use
cron and system tools as
start-stop-daemon. I mean, only the default tools)
Thank you so much for your time!
Debian will eventually have systemd, so this is the way to do it on a Linux system which uses systemd (and many do already; you might consider switching distributions).
Systemd can handle keeping the service alive for you automatically; no other tools are required. Simply make sure that
Restart=always is set in the service file’s
# vi /etc/systemd/system/dtnd.service [Service] Restart=always #...everything else...
Several other options are available as well, for more complex scenarios.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.