NAME
nohup — invoke a
utility immune to hangups
SYNOPSIS
nohup |
utility [argument ...] |
DESCRIPTION
The nohup utility shall invoke the utility
named by the utility operand with arguments supplied as the argument
operands. At the time the named utility is invoked, the
SIGHUP signal shall be set to be ignored. If the standard
output is a terminal, all output written by the named utility to its
standard output shall be appended to the end of the file
nohup. out in the current directory. If
nohup. out cannot be created or opened for
appending, the output shall be appended to the end of the file
nohup. out in the directory specified by the
HOME environment variable. If neither file can be created
or opened for appending, utility shall not be invoked. If a file is created,
the file’s permission bits shall be set to
S_IRUSR
|
S_IWUSR
instead of the default specified in 2.9.1.4. If the standard error is a
terminal, all output written by the named utility to its standard error
shall be redirected to the same file descriptor as the standard output.
OPTIONS
None.
OPERANDS
The following operands shall be supported by the implementation:
- utility
-
The name of a utility that is to be invoked. If the utility operand names any of the special built-in utilities in 3.14, the results are undefined.
- argument
-
Any string to be supplied as an argument when invoking the utility named by the utility operand.
STANDARD INPUT
None.
INPUT FILES
None.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
nohup:
HOME-
This variable shall determine the pathname of the user’s home directory: if the output file
nohup. out cannot be created in the current directory, thenohuputility shall use the directory named by HOME to create the file. LANG-
This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.
LC_ALL-
This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.
LC_CTYPE-
This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).
LC_MESSAGES-
This variable shall determine the language in which messages should be written.
PATH-
This variable shall determine the search path that shall be used to locate the utility to be invoked. See 2.6.
ASYNCHRONOUS EVENTS
The nohup utility shall take the standard
action for all signals (see 2.11.5.4), except that SIGHUP
shall be ignored.
STANDARD OUTPUT
If the standard output is not a terminal, the standard output of
nohup shall be the standard output generated by the
execution of the utility specified by the operands. Otherwise, nothing shall
be written to the standard output.
STANDARD ERROR
If the standard output is a terminal, a message shall be written
to the standard error, indicating the name of the file to which the output
is being appended. The name of the file shall be either
nohup. out or $ HOME /
nohup. out.
OUTPUT FILES
If the standard output is a terminal, all output written by the
named utility to the standard output and standard error is appended to the
file nohup. out, which is created if it does not
already exist.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The nohup utility shall exit with one of
the following values:
CONSEQUENCES OF ERRORS
Default.
RATIONALE
EXAMPLES
It is frequently desirable to apply nohup
to pipelines or lists of commands. This can be done by placing pipelines and
command lists in a single file; this file can then be invoked as a utility,
and the nohup applies to everything in the file.
Alternatively, the following command can be used to apply
nohup to a complex command:
nohup sh -c ’complex-command-line’ The
bc(1) BSD version ignores SIGTERM and
SIGHUP, and if ./ nohup. out
cannot be used, it fails instead of trying to use $ HOME /
nohup. out. The command, env,
nohup, and xargs utilities have been specified to
use exit code 127 if an error occurs so that applications can distinguish
‘‘failure to find a utility’’ from
‘‘invoked utility exited with an error
indication.’’ The value 127 was chosen because it is not
commonly used for other meanings; most utilities use small values for
‘‘normal error conditions’’ and the values above
128 can be confused with termination due to receipt of a signal. The value
126 was chosen in a similar manner to indicate that the utility could be
found, but not invoked. Some scripts produce meaningful error messages
differentiating the 126 and 127 cases. The distinction between exit codes
126 and 127 is based on KornShell practice that uses 127 when all attempts
to exec the utility fail with ENOENT, and uses 126
when any attempt to exec the utility fails for any other reason.
HISTORY OF DECISIONS MADE
The csh utility has a built-in version of
nohup that acts differently than this. The term
utility is used, rather than command, to highlight the fact that shell
compound commands, pipelines, special built-ins, etc., cannot be used
directly. However, utility includes user application programs and shell
scripts, not just the standard utilities. Historical versions of the
nohup utility use default file creation semantics.
Some more recent versions use the permissions specified here as an added
security precaution. Some historical implementations ignore
SIGQUIT in addition to SIGHUP; others
ignore SIGTERM. An earlier draft allowed, but did not
require, SIGQUIT to be ignored. Several members of the
balloting group objected, saying that nohup should
only modify the handling of SIGHUP as required by this
specification.