Running script in background on linux

If we want to run a script from terminal and be able to close the terminal without killing a script (because terminal would be a parent process, so if it dies, its children die automatically), here is the command:
nohup python python_script.py > python_script.out &
This will direct the stdout stream to file python_script.out
nohup tells OS to run program immune to hangups.
& tells OS to run program in background.
If we want to see updates coming python_script.out while the script runs in background, we can use a handy command:
tail -10f python_script.out

Advertisements
This entry was posted in Bash, Productivity, Programming, Python, UNIX/Linux, Vim and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s