# nohup

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## 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 standard input is associated with a terminal, the _nohup_ utility
           may redirect standard input from an unspecified file.
    
           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.
    
           If standard error is a terminal and standard output is open but is
           not a terminal, all output written by the named utility to its
           standard error shall be redirected to the same open file
           description as the standard output. If standard error is a
           terminal and standard output either is a terminal or is closed,
           the same output shall instead be appended to the end of the
           **nohup.out** file as described above.
    


## OPTIONS



           None.
    


## OPERANDS



           The following operands shall be 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 _Section 2.14_ , _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 shall 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 shall use the
                     directory named by _HOME_ to create the file.
    
           _LANG_      Provide a default value for the internationalization
                     variables that are unset or null. (See the Base
                     Definitions volume of POSIX.1‐2017, _Section 8.2_ ,
                     _Internationalization Variables_ for the precedence of
                     internationalization variables used to determine the
                     values of locale categories.)
    
           _LC_ALL_    If set to a non-empty string value, override the values
                     of all the other internationalization variables.
    
           _LC_CTYPE_  Determine the locale for the interpretation of sequences
                     of bytes of text data as characters (for example,
                     single-byte 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 catalogs for the
                     processing of _LC_MESSAGES_.
    
           _PATH_      Determine the search path that is used to locate the
                     utility to be invoked. See the Base Definitions volume
                     of POSIX.1‐2017, _Chapter 8_ , _Environment Variables_.
    


## ASYNCHRONOUS EVENTS



           The _nohup_ utility shall take the standard action for all signals
           except that SIGHUP shall be ignored.
    


## STDOUT



           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.
    


## STDERR



           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



           Output written by the named utility is appended to the file
           **nohup.out**(or **$HOME/nohup.out**), if the conditions hold as
           described in the DESCRIPTION.
    


## EXTENDED DESCRIPTION



           None.
    


## EXIT STATUS



           The following exit values shall be 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_ shall be that of the utility
           specified by the _utility_ operand.
    


## CONSEQUENCES OF ERRORS



           Default.
    
           _The following sections are informative._
    


## 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_ ' </dev/null
    


## RATIONALE



           The 4.3 BSD version ignores SIGTERM and SIGHUP, and if **./nohup.out**
           cannot be used, it fails instead of trying to use **$HOME/nohup.out**.
    
           The _csh_ utility has a built-in version of _nohup_ that acts
           differently from the _nohup_ defined in this volume of POSIX.1‐2017.
    
           The term _utility_ is used, rather than _command_ , to highlight the
           fact that shell compound commands, pipelines, special built-ins,
           and so on, 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 early proposal allowed, but did
           not require, SIGQUIT to be ignored. Several reviewers objected
           that _nohup_ should only modify the handling of SIGHUP as required
           by this volume of POSIX.1‐2017.
    
           Historical versions of _nohup_ did not affect standard input, but
           that causes problems in the common scenario where the user logs
           into a system, types the command:
    
               nohup make &
    
           at the prompt, and then logs out. If standard input is not
           affected by _nohup_ , the login session may not terminate for quite
           some time, since standard input remains open until _make_ exits. To
           avoid this problem, POSIX.1‐2008 allows implementations to
           redirect standard input if it is a terminal. Since the behavior is
           implementation-defined, portable applications that may run into
           the problem should redirect standard input themselves. For
           example, instead of:
    
               nohup make &
    
           an application can invoke:
    
               nohup make </dev/null &
    


## FUTURE DIRECTIONS



           None.
    


* * *