Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to run a different command when upstart is restarting a process than when it is starting a process. In particular, I'm using Thin and I want to do a rolling restart (built in to thin via a different command) instead of stopping/starting.

Is this possible with upstart, or do I need to start looking for a different solution?

share|improve this question

1 Answer 1

Its not possible like that. Job itself doesn't know it is restarting.

I suggest you simply use two different jobs. Job A that does the first variant and Job B that starts up when Job A fails. There is extra information attached to stoppingevent of Job A in case it fails (see http://upstart.ubuntu.com/cookbook/#id109 ), so Job B should have start on stanza such as:

start on stopping JobA RESULT=failed



to keep it up. respawnshould not be added to Job A at all.

This was the job will not start if Job A successfully exits, but only on an error condition.

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.