Run a python script that is never Killed

6,550

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:
6,550

Related videos on Youtube

donald
Author by

donald

Updated on September 18, 2022

Comments

  • donald
    donald over 1 year

    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?

    • Kyle Smith
      Kyle Smith about 12 years
      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.
  • donald
    donald about 12 years
    I use screen but the script seems to be killed without any error.
  • donald
    donald about 12 years
    I use screen but the script seems to be killed without any error.