cancel
Showing results for 
Search instead for 
Did you mean: 

nohup command

gany59
Regular Advisor

nohup command

what is the use of nohup command, and how can we use that.

Please any body let me know that. Thanks in advance!
12 REPLIES
g3jza
Esteemed Contributor

Re: nohup command

Hi,

#man nohup

it is used to redirect standard output/error to a file.
sangilak
Trusted Contributor

Re: nohup command

Hi,


From the man page:

DESCRIPTION

nohup executes command with hangups and quits ignored. If output is not redirected by the user, both standard output and standard error are sent to nohup.out. If nohup.out is not writable in the current directory, output is redirected to $HOME/nohup.out; otherwise, nohup fails. If a file is created, the file's permission bits will be set to S_IRUSR | S_IWUSR.

If output from nohup is redirected to a terminal, or is not redirected at all, the output is sent to nohup.out.

Source: http://docs.hp.com/en/B2355-90680/nohup.1.html


Hope that helps,

sangilak
Michal Kapalka (mikap)
Honored Contributor

Re: nohup command

hi,

simple explanation of nohup :

runs a command even if the session is disconnected or the user logs out.

mikap
Dennis Handly
Acclaimed Contributor

Re: nohup command

What problem are you trying to solve? Typically if it is SIGHUP/hangups, then nohup is the solution.
Wilfred Chau_1
Respected Contributor

Re: nohup command

wiki :-)
http://en.wikipedia.org/wiki/Nohup

usually you use it with a command to run in the background, or want the command to continue to run after you exit out of the terminal from where you issue the command.
gany59
Regular Advisor

Re: nohup command

ok folks,

Say for an example, if i want to run the ignite backup, can i use the below format:

#nohup make_tape_recovery -A -i -x /dev/rmt/0mn

Or any other synopsis required for the nohup..

Thanks!
g3jza
Esteemed Contributor

Re: nohup command

#nohup make_tape_recovery -A -i -x /dev/rmt/0mn &

Use the '&' if you want to run it in background
gany59
Regular Advisor

Re: nohup command

ok g3jza,

if u want to run the command, once i exit from my terminal also means ?
g3jza
Esteemed Contributor

Re: nohup command

Yes, when you exit from the terminal then the command should continue executing
g3jza
Esteemed Contributor

Re: nohup command

One example on this:

Using 'find' as an example:

#find / -name '*txt' & (to find any txt-files )

your nohup.out output will be growing.

At the same time try to logout from your current terminal. Then open a new terminal and make a
#tail -f nohup.out
or
#ps -ef|grep find

to find out that the command is still executing and the number of txt files is growing in the nohup.out

Mike Miller_8
Regular Advisor

Re: nohup command

Here's a general example of running a job in the background and capturing the output :

nohup nice -19 command > command.out 2>&1 &

Where command is the command that you want to run and command.out is the captured output. The "nice -19" just lowers the priority so that if you have a slow machine it will not slow down your forground jobs (like typing).
Wilfred Chau_1
Respected Contributor

Re: nohup command

Here is a good read for you

http://techsubmit.com/204/nohup-execute-command-in-background-even-after-exiting-a-shell-prompt/

also nohup will create a nohup.out file if stdout/stderr is not redirected. So make sure you monitor it, as it could grow and fill up your filesystem.