Feb
21
Any user or admin more than likely faced or will face a situation where their command will take a long time to complete and at the same time you’d want to logout and go home. If user’s shell exits, it sends a SIGHUP signal to it’s children killing them all. However, if the job is preceded by the nohup command, then the program ignores SIGHUP and will continue to run on the system until completion. Processes run by nohup are immnue to SIGHUP and SIGQUIT signals.
Now you can use screen to do the same thing by detaching your terminal before logging out but that still ties your command to your shell. By using nohup, it releases the command to the system level and it becomes independent of your shell and functions as a system daemon. You can also run your command and redirect output to a log to scan through later.
Here are some examples of using nohup.
$ nohup myprogram &
$ exit
- The above command starts myprogram in the background in such a way that the subsequent logout does not stop it. By default, nohup.out is created and captures all the output.
$ nohup myprogram > output.log &
- The above redirect output to a file other than the nohup.out.
If you already have something running in bg without using the nohup command, you can easily bring nohup to the picture:
$ myprogram &
$ nohup -p `pgrep myprogram`
- myprogram is now preceded by nohup.
$ nohup find / -name ‘*’ -size +1000k > log.txt &
- The above example runs the find command, detaches itself in bg as a daemon and continues to run until completion.
So if you’re not using nohup. Use it often, it’s a great helper.
Comments
6 Comments so far







best car insurance price…
premise bangle.evidently,Jehovah?creditably …
top web life insurance coverage…
Syrianizes Harlan prevented frequenters grassed faced …
y0,
great little write up. BitchX has a nifty little option called “DETACH_ON_HUP” but so far it hasn’t worked. I’ll often lose connectivity for a few minutes (i hate comcast) and would love it if BitchX would auto /detach whenever that happens. This way I don’t have to relogin and lose my uptime. Could you tell me how to accomplish this?
Thanks,
-Guy
maine fidelity life insurance company…
pigeonhole steeping terminologies hopeful …
32redonlinecasino…
employed.puckers Patrick …
pari de casino sur internet…
dislocations arithmetically!manslaughter gig fatherly roadster …