0

I want my python program sample.py 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/.

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

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

script
  logger "just before executing sample.sh"
  exec /usr/bin/python /home/magic/Documents/gearman-python/Worker.py
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.

1 Answer 1

1

Put the script in /etc/init or read cookbook section about enabling user jobs: http://upstart.ubuntu.com/cookbook/#id96

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .