Next: , Previous: , Up: Modified command invocation   [Contents][Index]

23.4 nohup: Run a command immune to hangups

nohup runs the given command with hangup signals ignored, so that the command can continue running in the background after you log out. Synopsis:

nohup command [arg]…

If standard input is a terminal, redirect it so that terminal sessions do not mistakenly consider the terminal to be used by the command. Make the substitute file descriptor unreadable, so that commands that mistakenly attempt to read from standard input can report an error. This redirection is a GNU extension; programs intended to be portable to non-GNU hosts can use ‘nohup command [arg]… 0>/dev/null’ instead.

If standard output is a terminal, the command’s standard output is appended to the file nohup.out; if that cannot be written to, it is appended to the file $HOME/nohup.out; and if that cannot be written to, the command is not run. Any nohup.out or $HOME/nohup.out file created by nohup is made readable and writable only to the user, regardless of the current umask settings.

If standard error is a terminal, it is normally redirected to the same file descriptor as the (possibly-redirected) standard output. However, if standard output is closed, standard error terminal output is instead appended to the file nohup.out or $HOME/nohup.out as above.

To capture the command’s output to a file other than nohup.out you can redirect it. For example, to capture the output of make:

nohup make > make.log

nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an ‘&’. Also, nohup does not alter the niceness of command; use nice for that, e.g., ‘nohup nice command’.

command must not be a special built-in utility (see Special built-in utilities).

The only options are --help and --version. See Common options. Options must precede operands.

Exit status:

125 if nohup itself fails, and POSIXLY_CORRECT is not set
126 if command is found but cannot be invoked
127 if command cannot be found
the exit status of command otherwise

If POSIXLY_CORRECT is set, internal failures give status 127 instead of 125.

Next: , Previous: , Up: Modified command invocation   [Contents][Index]