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 my python program to be always up and running. I have read some things and asked people about ways to do this. So far I have following options -

  • Upstart
  • Cron

I am trying things with upstart right now. I have created a sample.conf in $HOME/.init/.

description "gearmanWorker1"
author "hussain"
pre-start script
  logger "pre-start for sample"
end script

post-start script
  logger "post-start for sample"
end script

  logger "just before executing"
  exec /usr/bin/python /home/magic/Documents/gearman-python/
end script

But when I do sudo initctl start sample / sudo start sample it says -

start: Unknown job: sample

When I do status sample, it says -

sample stop/waiting

which means sample process is not running yet.
I don't know if I am doing this right; I am very new to this. Also I don't think cron will be the best way to achieve what I want. Because I just want to monitor sample in such a way that it will automatically restart after a failure/abort. It should also restart after a reboot.

Also feel free to suggest any other better ways to do this.

share|improve this question

Put the script in /etc/init or read cookbook section about enabling user jobs:

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.