The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

nohup - invoke a utility immune to hangups

 SYNOPSIS



nohup utility [argument...]

 DESCRIPTION

The nohup utility will 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 is set to be ignored.

If the standard output is a terminal, all output written by the named utility to its standard output will 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 will 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 will not be invoked. If a file is created, the file's permission bits will be set to S_IRUSR | S_IWUSR.

If the standard error is a terminal, all output written by the named utility to its standard error will be redirected to the same file descriptor as the standard output.

 OPTIONS

None.

 OPERANDS

The following operands are supported:
utility
The name of a utility that is to be invoked. If the utility operand names any of the special built-in utilities in Special Built-in Utilities , the results are undefined.
argument
Any string to be supplied as an argument when invoking the utility named by the utility operand.

 STDIN

Not used.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of nohup:
HOME
Determine the pathname of the user's home directory: if the output file nohup.out cannot be created in the current directory, the nohup utility will use the directory named by HOME to create the file.
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .
PATH
Determine the search path that will be used to locate the utility to be invoked. See the XBD specification, Environment Variables  .

 ASYNCHRONOUS EVENTS

The nohup utility will take the standard action for all signals except that SIGHUP will be ignored.

 STDOUT

If the standard output is not a terminal, the standard output of nohup will be the standard output generated by the execution of the utility specified by the operands. Otherwise, nothing will be written to the standard output.

 STDERR

If the standard output is a terminal, a message will be written to the standard error, indicating the name of the file to which the output is being appended. The name of the file will 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 following exit values are returned:
126
The utility specified by utility was found but could not be invoked.
127
An error occurred in the nohup utility or the utility specified by utility could not be found.

Otherwise, the exit status of nohup will be that of the utility specified by the utility operand.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

The command, env, nice, nohup, time 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.

 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'

 FUTURE DIRECTIONS

None.

 SEE ALSO

sh, the XSH specification description of signal().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]