Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nohup command

Status
Not open for further replies.

goldenradium2001

Technical User
Mar 22, 2002
91
0
0
US
Just to learn what nohup can do, I executed the command:

# find -name grep a / '{}' \; -print > newfile &

nohup is supposed to keep executing this command in the background even though I log out. The thing is, I executed this command, logged out, then logged back in. The process was still running!! I thought the process wouldn't run without the nohup command.

Anyone have an explanation for this?

Thanks.
 
As far as I know, when you log out, processes you run receive SIGHUP. They don't have to terminate; the only signal leading to termination without excuses is SIGKILL. Nohup just blocks SIGHUP, so named processes don't receive it at all.
 
The nohup utility invokes the named command with the arguments supplied. When the command is invoked, nohup arranges for the SIGHUP signal to be ignored by the process.

The nohup utility can be used when it is known that command will take a long time to run and the user wants to logout of the terminal; when a shell exits, the system sends its children SIGHUP signals, which by default cause them to be killed. All stopped, running, and background jobs will ignore SIGHUP and continue running, if their invocation is preceded by the nohup command or if the process programmatically has chosen to ignore SIGHUP.

Using the (&) ampersand after a process invokes the background command. This allow the command to be performed in the background while the terminal is running.

What is likely happening is that the background is being invoked and then the job is being terminated but the terminated command is leaving just that a termination. You could try fg %job job being the job number. Its also likely that the command is not being properly terminated are you trying this as root or a standard user?

Typing jobs will show you if there are any background jobs currently running. John D. Saucier
jsauce@magicguild.com
Certified Technician
Network Administrator
 
Thanks for the explanations. :) Can you give me an example of a process where nohup would be used?

Thanks.
 
You nohup any command you want to run when you're not logged in. Basically if tyou wanted to run a utility that you knew would take a few hours to finish, you could nohup it and it will normally redirect any output to nohup.out. I normally nohup SETI for example. SETI can run in the background when I'm not around and it will continue to do its thing. It will allow other users to login and do their thing while its running. John D. Saucier
jsauce@magicguild.com
Certified Technician
Network Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top