Super User is a question and answer site for computer enthusiasts and power users. 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 have a very simple Python script that I'd like to be always running on my ubuntu 12.04 server. I thought of using upstart + monit. Problem is that those tools seem rather complicated for a simple mortal like me, and I cannot find a simple example on the web.

Is upstart + monit overkill ? / Does somebody know a simpler alternative ? / or a good tutorial ?

share|improve this question
    
As I just want the script to be running, isn't upstart enough ? Monit is needed only to make a test periodically right !? – sebpiq Aug 14 '12 at 14:28
up vote 8 down vote accepted

Taken from this answer:

You could write a bash script monitor.sh which starts your python script and restarts it if it crashes but doesn't restart if the script exits normally:

#!/bin/bash
until myscript.py; do
    echo "'myscript.py' crashed with exit code $?. Restarting..." >&2
    sleep 1
done

Then just start the monitor script in background:

nohup monitor.sh &

As an alternative to nohup, you may also consider tmux or screen for running background processes.

share|improve this answer
    
Works like a charm, and so easy ! Thanks :) – sebpiq Aug 14 '12 at 14:59

You must log in to answer this question.

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