Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want Upstart to do two things:

  1. stop trying to respawn a failed process so fast
  2. never give up trying to respawn

In an ideal world, upstart would try to restart a dead process after 1s, then double that delay on each attempt, until it reached an hour.

Is something like this possible?

share|improve this question

4 Answers 4

up vote 9 down vote accepted

The Upstart Cookbook recommends a post-stop delay (http://upstart.ubuntu.com/cookbook/#delay-respawn-of-a-job). Use the respawn stanza without arguments and it will continue trying forever:

post-stop exec sleep 5

(I got this from http://askubuntu.com/questions/52309/respawning-too-fast-stopped-how-to-make-upstart-disable-for-5-mins.)

To add the exponential delay part, I'd try working with an environment variable in the post-stop script, I think something like:

post-stop script
    sleep $SLEEP_TIME
    if [ $NEW_SLEEP_TIME -ge 60 ]; then
    initctl set-env SLEEP_TIME=$NEW_SLEEP_TIME
end script
share|improve this answer

You want respawn limit <times> <period> - although this would not provide the exponential behavior you are looking for, it probably would do for most use cases. You might try using very large values for times and period to approximate what you try to achieve. See the man 5 init's section on respawn limit for reference.

share|improve this answer
The period is the period in which respawns are counted, not a delay between respawns. –  chrisdew Jan 28 '13 at 10:25

I ended up putting a start in a cronjob. If the service is running, it has no effect. If it's not running, it starts the service.

share|improve this answer

As already mentioned, use respawn to trigger the respawn.

However, the Upstart Cookbook coverage on respawn-limit says that you'll need to specify respawn limit unlimited to have continual retry behaviour.

By default it will retry as long as the process doesn't respawn more than 5 times in 10 seconds.

I would therefore suggest:

respawn limit unlimited
post-stop <script to back-off or constant delay>
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.