1819828 Members
3041 Online
109607 Solutions
New Discussion юеВ

what is nohup?

 
SOLVED
Go to solution
Lalo_Weng
Advisor

what is nohup?

Hi, I want to know what is nohup? Why nohup?

Thanks.
Keep finding is the way.
8 REPLIES 8
Patrick Chim
Trusted Contributor
Solution

Re: what is nohup?

Hi,

nohup means 'no hang up'. When you login in a system and type some command or executing script in command prompt, it will hold up for a while until the job is finished. During this time, there is no prompt and you cannot execute anything. But with 'nohup' before your command, it will execute the job at the background and at the same time, you can still type any other command at the prompt which do not bother your previous job !

Regards,
Patrick
Steven Sim Kok Leong
Honored Contributor

Re: what is nohup?

Hi,

Use nohup (no hang-up) so that your background processes do not get terminated when you exit your login session eg.

$ nohup forever_running_script &

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Deepak Extross
Honored Contributor

Re: what is nohup?

see 'man nohup'.
its documented quite well there.
Lalo_Weng
Advisor

Re: what is nohup?

Do we have to put a '&' after the command when we issue the command with 'nohup'? What is means when you put a '&' after the command?
Keep finding is the way.
Steven Sim Kok Leong
Honored Contributor

Re: what is nohup?

Hi,

& means run the process in the background.

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Marcin Wicinski
Trusted Contributor

Re: what is nohup?

Hi,
nohup makes started process to ignore hangup and quit signals, thus our process wont die when his parent dies.
Best way to run a process with nohup is:

# nohup our_process &

Run it in background.

Marcin Wicinski
Bill McNAMARA_1
Honored Contributor

Re: what is nohup?

if you use the &
and have done it lots of times,
use teh command jobs
to figure out what 'jobs' are in the background

bring them to the foreground with fg %jobid
You can kill with kill %job

Later,
Bill
It works for me (tm)
Darrell Allen
Honored Contributor

Re: what is nohup?

Hello,

I think previous replies may cause some confusion.

Nohup has nothing to do with putting a process in the background. Appending an "&" to your command line causes that process to run in the background.

Nohup has everything to do with keeping a process running after you "hang up" the connection.

An example of when I run a nohup process is when I need to dial-in, start a long-running process, and hang up the connection. The job needs to be started with nohup put in the background so I can logout without the job quitting.

Also, by default output is written to nohup.out so you may want to redirect stdout and stderr when nohup'ing a process. I'd use:
nohup command line with args >output_filename 2>&1 &

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)