Run a detached program (daemon) from a linux shell command line prompt.
Simon Tite
6:55 am on November 5, 2009
nohup any-command &
This is something I find useful, when I might need to edit a file I have just found, but I don’t want to tie up the terminal session, and as I’m already in a terminal session, I don’t want to have to mouse around the screen to start my editor, navigate to the file, open it, etc. Neither do I want the editor to terminate if I accidentally terminate the terminal session.
Example: nohup edit myfile.txt &
Explanation for the morbidly curious:
The ampersand at the end of any shell command means “run in a separate process”. This spawns a new shell to run the command, however the new shell is dependent on the calling shell: when the calling shell terminates, so will the child shell.
The nohup command tells the root process to spawn as a child of the root process, thus it will continue to live on, even when its parent dies…
“nohup” as far as I know owes its name to the days of dial-in timeshare systems, where you would be charged by the minute actually connected to the system. Using “nohup”, you could spawn a lengthy process, then hang up (disconnect) the telephone, and return later to see the results of the job, avoiding excessive connect time. “nohup” means “no hang up”.
Simon Tite 6:55 am on November 5, 2009
nohup any-command &This is something I find useful, when I might need to edit a file I have just found, but I don’t want to tie up the terminal session, and as I’m already in a terminal session, I don’t want to have to mouse around the screen to start my editor, navigate to the file, open it, etc. Neither do I want the editor to terminate if I accidentally terminate the terminal session.
Example:
nohup edit myfile.txt &Explanation for the morbidly curious:
The ampersand at the end of any shell command means “run in a separate process”. This spawns a new shell to run the command, however the new shell is dependent on the calling shell: when the calling shell terminates, so will the child shell.
The nohup command tells the root process to spawn as a child of the root process, thus it will continue to live on, even when its parent dies…
“nohup” as far as I know owes its name to the days of dial-in timeshare systems, where you would be charged by the minute actually connected to the system. Using “nohup”, you could spawn a lengthy process, then hang up (disconnect) the telephone, and return later to see the results of the job, avoiding excessive connect time. “nohup” means “no hang up”.