How to keep a program running in the background using 'nohup'
How to keep a program running in the background using 'nohup'
Let's say you want to run yourprogram in the background, logging both stdout and stderr to log.txt:
# yourprogram > log.txt 2>&1 &
# exit
# YOUR PROGRAM WILL RECEIVE A HANGUP SIGNAL AND TERMINATE!
The problem is when you exit your session, all you processes created in the current session normally receives the hangup (HUP) signal, which makes them to terminate.
Using nohup, your program will be immune to HUP, and will continue even when you exit:
# nohup yourprogram > log.txt 2>&1 &
# exit
# YOUR PROGRAM WILL CONTINUE AND BE HAPPY!
Last modified: Wed Mar 21 15:50:33 Romance Standard Time 2007