Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a script running python script.py in a new screen but sometimes the script gets killed:

18
21
Restarting processes... done
2
Killed

How can I protect the script from being killed even when I close the console? Shall I use & or nohup?

share|improve this question
    
Are you the sole administrator of the system? I just did a quick test and that "Killed" output is not what is displayed when you send Python a SIGKILL or SIGTERM. –  Kyle Smith Feb 27 '12 at 0:08

2 Answers 2

Do you mean it is running inside a GNU screen session? In this case, it shouldn't get killed unless there is some problem with the script and it terminates due to this problem.

If you don't use screen, use start using it or tmux (which I like more).

share|improve this answer
    
I use screen but the script seems to be killed without any error. –  donald Feb 26 '12 at 22:35

I would recommend adding this code to your script http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/

Or use screen.

Edit: This is a little more modern but I haven't used it(I use something custom) http://pypi.python.org/pypi/python-daemon

share|improve this answer
    
I use screen but the script seems to be killed without any error. –  donald Feb 26 '12 at 22:35

Your Answer

 
discard

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.