Have python script run in background of unix Have python script run in background of unix unix unix

Have python script run in background of unix


yes, by running your python script with nohup (no hangup), your script won't keel over when the network is severed and the trailing & symbol will run your script in the background.

You can still view the output of your script, nohup will pipe the stdout to the nohop.out file. You can babysit the output in real time by tailing that output file:

$ tail -f nohop.out

quick note about the nohup.out file...

nohup.out          The output file of the nohup execution if                   standard  output is a terminal and if the                   current directory is writable.

or append the command with & to run the python script as a deamon and tail the logs.

$ nohup python python_script.py > my_output.log &$ tail -f my_output.log


You can use nohup

  1. chomd +x /path/to/script.py
  2. nohup python /path/to/script.py &

Or

Instead of closing your terminal, use logout It is not SIGHUP when you do logout thus the shell won't send a SIGHUP to any of its children.children.