[Previous] [Contents] [Index] [Next]

nohup

Invoke a command immune to hangups (POSIX)

Syntax:

nohup command [argument...]

Options:

argument
The argument(s) for the command to be invoked.

Description:

The nohup utility invokes the specified command with arguments supplied as the argument operands. When the command is invoked, the SIGHUP signal is set to be ignored; thus, the command is made immune to hangups.

If the standard output is a terminal, all output written by the specified command to its standard output is appended to the nohup.out file in the current directory. If this nohup.out file can't be created, or if it can't be opened for appending, the output is appended to the end of the nohup.out file in the directory specified by the HOME environment variable. If neither nohup.out file can be created or opened, the specified command isn't invoked.

If the standard error output is a terminal, all output written by the specified command to its standard error output is redirected to the same file descriptor as the standard output.

It's often desirable to apply nohup to pipelines or lists of commands. You can do this by placing pipelines and command lists in a single file; this file can then be executed as a command, and the "nohup" applies to everything in the file.

Alternatively, the following can be used to apply nohup to a complex command:

nohup sh -c 'complex-command-line'

Similarly, you can use the following commands to apply nohup to a shell function:

export -f func
nohup sh -c 'command line invoking func'

If you want the SIGQUIT signal to also be ignored, you can run nohup in the background:

nohup command &

Files:

./nohup.out
If possible, this file will be created and the output of the command will be written to it.
$HOME/nohup.out
If it was not possible to open ./nohup.out, nohup will attempt to create (if necessary) and append the output of the command to this file. If neither file can be opened, nohup will not run the command.

Environment variables:

HOME
If the output file nohup.out cannot be created in the current directory, nohup uses the directory named by this variable to create the file.
PATH
Contains the search path used to locate the command to be invoked.

Exit status:

The exit status of nohup cannot be relied upon.

License:

This utility is based on copyright software of The Regents of the University of California; for the copyright notice, see nohup in the appendix Third-Party Copyright Notices.


[Previous] [Contents] [Index] [Next]