Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a golang program that I want to restart after it terminates on a Debian Squeeze box. The thing is serving HTTP behind an Apache 2 mod_proxy setup. I don't expect the process to fail, but I'd like to have some insurance against it.

On Ubuntu I would have used upstart to keep the process alive. Debian doesn't like Upstart from what I understand as it is an init replacement.

Is there an alternative which restarts one or more processes after they terminate that works on Squeeze and plays nice with init?

share|improve this question
Would you please rephrase your question? Is it that you want to restart a process after it has been terminated? – mailq Aug 6 '11 at 9:47
I'd like to restart a process automatically if it faults or terminates itself. – Deleted Aug 6 '11 at 9:48
The traditional init program does precisely this. Why people thought it would be a good idea to use init to run a shell script invoking a shell script that starts another process that does the same thing, but without an automatic kernel panic and reboot should that process ever fail, is completely beyond me. – Simon Richter Aug 6 '11 at 14:53
That's a fair point. I'll investigate just using init as well. I'm packaging the software using dpkg so creating init scripts shouldn't be a hardship. – Deleted Aug 6 '11 at 17:07
up vote 9 down vote accepted

The best way to go for it are the daemontools. They allow you to monitor and respawn processes.

See the documentation on their website:

share|improve this answer
Thanks - that's just what I'm after. DJB = good as a rule. I should actually have remembered that existed what with spending 5 years looking after qmail! – Deleted Aug 6 '11 at 11:09
Same with me, except that I used to look after djbdns for quite some time. – mr.b Feb 12 '13 at 11:14

supervise is a lightweight, efficient alternative. Under debian it is packaged in daemontools. You can also read this related question, which lists some supervise criticisms, and mentions restartd as another possibility.

Finally, if you want something incredibly easy to setup, I've had great success with monit. It is also packaged in Debian.

share|improve this answer
daemontools is awesome; monit is a freaking nightmare of "why the hell won't you start?!?" frustration. – womble Aug 6 '11 at 10:19

supervise or monit are good for keeping a single process alive. Since you ask for keeping "one or more" processes alive, I would like to plug supervisord. It is certainly overkill for managing a single process, but if you need to keep track of multiple processes it may be your thing.

share|improve this answer

One option is to use /etc/inittab instead of putting your script in /etc/init.d/.

You simply add an entry in the following format:


Unfortunately this means you cannot use the normal start/stop/restart init commands, but it should ensure your script is running all the time.

share|improve this answer

The cross distribution way of handling process re-starts is with cron and a simple script. You can see a writeup here How to keep a job running in Linux

The script looks something like

# make sure a process is always running.  
# Add the following to the crontab (i.e. crontab -e)
# */5 * * * * /home/path_to_make_run/


if pgrep $process > /dev/null         
  $makerun &         
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.