Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

System is Debian Whezy x64. I currently use screen to start programs as user rather than root. It looks like this: In /etc/rc.local, I call

su -c "/home/user/scripts/startup" user

Then, in /home/user/scripts/startup, I call a few python programs like this:

screen -dmS my_program python /home/user/ 

They all start fine. The problem is that these programs tend to update themselves every week or so. When the program updates, it tries to restart itself. Upon the program's restart, the screen session terminates, and the program does not start again. So, after a few days, I notice the program isn't working and need to start it again by hand.

Is there something I can do to ensure that the program will start itself again after a program restart?

Edit: I've read something about screen's "zombie mode" that allows it to stay active, but I don't know how to invoke it at boot.


share|improve this question
Within screen and within a shell script: ‛while : ; do myprogram ; done‛ – ott-- Jan 24 '13 at 22:51
up vote 1 down vote accepted

Create a script that runs in infinite loop and watches that program is running.

while true; do ps aux | grep -v grep | grep -q <program> || <start_program>; sleep 5; done

Start the script in screen.

share|improve this answer
I used the same idea, but was not as fancy. Just used Ott's While Do Done example. Thanks! – Oddworld Jan 29 '13 at 16:59

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.