Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 want to have a process which will be restarted if it crashes. I googled a bit and found that an easy solution is to use daemontools.

I didn't understand how to configure it.

  1. What is the easiest way to acomplish such a functionality?
  2. How to configure it?
share|improve this question
up vote 22 down vote accepted

This answer applies to Ubuntu versions with Upstart (<= 14.10). Use another approach for versions with Systemd (>= 15.04).

It seems you're looking for a functionality already provided in Ubuntu with Upstart. The respawn stanza in the configuration will do exactly what you need. I would recommend against the use of a less standard way of dealing with this.

Without more details about the process you're trying to manage with it, it's hard to say what the configuration should look like. It depends on whether it forks and puts itself in the background for example. The Upstart documentation on the respawn stanza should give you more information.

Unfortunately, it's not yet possible to run User Jobs properly: cannot get upstart to run user job


Let's assume we want to keep the Calculator app running, even when it's being killed with fire (signal 9).

  1. Create a configuration file in /etc/init/calculator.conf (based on this article):

    description "Calculator"
    # Start job via the daemon control script. Replace "gert" with your username.
    exec su -l gert -c 'export DISPLAY=:0; /usr/bin/gnome-calculator'
    # Restart the process if it dies with a signal
    # or exit code not given by the 'normal exit' stanza.
    # Give up if restart occurs 10 times in 90 seconds.
    respawn limit 10 90
  2. Start it by running

    sudo start calculator
  3. It opens on your current display (:0) and enjoy the awesomeness by seeing it restarting after closing it.

    • Identify the process ID, e.g. by doing ps aux | grep calculator:

      gert  13695 0.2 0.4 349744 16460 ?   Sl   13:38   0:00 /usr/bin/gnome-calculator
    • Kill it with fire.

      sudo kill -9 13695
    • Watch it reappearing:

      gert  16059 4.6 0.4 349736 16448 ?   Sl   13:40   0:00 /usr/bin/gnome-calculator

Note that this will be more elegant with the plans for the Ubuntu 13.04 plans with proper User Job support.

share|improve this answer
I get unknown job when i try to start it ? any ideea . i have placed the file in /etc/init – opc0de Feb 5 '13 at 13:19
@opc0de The name of the file servicename.conf has to match the command to start start servicename. I suspect you have chosen a different name. – gertvdijk Feb 5 '13 at 13:23
nope, it matches but I didn't follow your example so i think I might have an syntax error. – opc0de Feb 5 '13 at 13:26
@opc0de Well, start by explaining more about what you're trying to accomplish in the question: what kind of application/process and how you run it for example, as well as the details about your current attempt. – gertvdijk Feb 5 '13 at 15:18
Solved with your example my mistake was that i probably had a mistake into the exec statament. Thanks for your help! – opc0de Feb 5 '13 at 17:58

There is a way without "Upstart". The keyword is "inittab" :-). Although that's a file not usually altered from default, it can be used to achieve the desired respawning on SYSV machines.

share|improve this answer
I don't understand why someone REJECTED this solution. If you don't understand it, just google it; it's pointless to cut and paste here the man pages of initttab, you can read them yourself on your system! just type "man inittab"... – cepal67 Jun 16 '15 at 14:26
High quality answers detail more than "use this, figure it out on your own" :) – Seth Jun 17 '15 at 0:13

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.