1NOHUP(1P)                  POSIX Programmer's Manual                 NOHUP(1P)
2
3
4

PROLOG

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

NAME

13       nohup — invoke a utility immune to hangups
14

SYNOPSIS

16       nohup utility [argument...]
17

DESCRIPTION

19       The nohup utility shall invoke the utility named by the utility operand
20       with arguments supplied as the argument operands. At the time the named
21       utility is invoked, the SIGHUP signal shall be set to be ignored.
22
23       If standard input is associated with a terminal, the nohup utility  may
24       redirect standard input from an unspecified file.
25
26       If  the  standard output is a terminal, all output written by the named
27       utility to its standard output shall be appended to the end of the file
28       nohup.out  in  the current directory. If nohup.out cannot be created or
29       opened for appending, the output shall be appended to the  end  of  the
30       file nohup.out in the directory specified by the HOME environment vari‐
31       able. If neither file can be created or opened for  appending,  utility
32       shall  not be invoked. If a file is created, the file's permission bits
33       shall be set to S_IRUSR | S_IWUSR.
34
35       If standard error is a terminal and standard output is open but is  not
36       a  terminal,  all  output  written by the named utility to its standard
37       error shall be redirected to the same  open  file  description  as  the
38       standard  output.  If  standard error is a terminal and standard output
39       either is a terminal or is closed, the same  output  shall  instead  be
40       appended to the end of the nohup.out file as described above.
41

OPTIONS

43       None.
44

OPERANDS

46       The following operands shall be supported:
47
48       utility   The  name  of a utility that is to be invoked. If the utility
49                 operand names any of the special built-in utilities  in  Sec‐
50                 tion  2.14, Special Built-In Utilities, the results are unde‐
51                 fined.
52
53       argument  Any string to be supplied as an argument  when  invoking  the
54                 utility named by the utility operand.
55

STDIN

57       Not used.
58

INPUT FILES

60       None.
61

ENVIRONMENT VARIABLES

63       The  following  environment  variables  shall  affect  the execution of
64       nohup:
65
66       HOME      Determine the pathname of the user's home directory:  if  the
67                 output file nohup.out cannot be created in the current direc‐
68                 tory, the nohup utility shall use the directory named by HOME
69                 to create the file.
70
71       LANG      Provide  a  default  value for the internationalization vari‐
72                 ables that are unset or null. (See the Base Definitions  vol‐
73                 ume  of POSIX.1‐2008, Section 8.2, Internationalization Vari‐
74                 ables for the precedence  of  internationalization  variables
75                 used to determine the values of locale categories.)
76
77       LC_ALL    If  set  to  a non-empty string value, override the values of
78                 all the other internationalization variables.
79
80       LC_CTYPE  Determine the locale for the interpretation of  sequences  of
81                 bytes of text data as characters (for example, single-byte as
82                 opposed to multi-byte characters in arguments).
83
84       LC_MESSAGES
85                 Determine the locale that should be used to affect the format
86                 and  contents  of  diagnostic  messages  written  to standard
87                 error.
88
89       NLSPATH   Determine the location of message catalogs for the processing
90                 of LC_MESSAGES.
91
92       PATH      Determine  the search path that is used to locate the utility
93                 to  be  invoked.  See  the   Base   Definitions   volume   of
94                 POSIX.1‐2008, Chapter 8, Environment Variables.
95

ASYNCHRONOUS EVENTS

97       The nohup utility shall take the standard action for all signals except
98       that SIGHUP shall be ignored.
99

STDOUT

101       If the standard output is not a terminal, the standard output of  nohup
102       shall  be the standard output generated by the execution of the utility
103       specified by the operands. Otherwise, nothing shall be written  to  the
104       standard output.
105

STDERR

107       If the standard output is a terminal, a message shall be written to the
108       standard error, indicating the name of the file to which the output  is
109       being  appended.  The  name  of  the  file shall be either nohup.out or
110       $HOME/nohup.out.
111

OUTPUT FILES

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

EXTENDED DESCRIPTION

118       None.
119

EXIT STATUS

121       The following exit values shall be returned:
122
123       126     The utility specified by utility was found  but  could  not  be
124               invoked.
125
126       127     An error occurred in the nohup utility or the utility specified
127               by utility could not be found.
128
129       Otherwise, the exit status of nohup shall be that of the utility speci‐
130       fied by the utility operand.
131

CONSEQUENCES OF ERRORS

133       Default.
134
135       The following sections are informative.
136

APPLICATION USAGE

138       The  command,  env,  nice,  nohup,  time, and xargs utilities have been
139       specified to use exit code 127 if an error occurs so that  applications
140       can  distinguish  ``failure  to find a utility'' from ``invoked utility
141       exited with an error indication''. The value 127 was chosen because  it
142       is  not commonly used for other meanings; most utilities use small val‐
143       ues for ``normal error conditions'' and the values  above  128  can  be
144       confused with termination due to receipt of a signal. The value 126 was
145       chosen in a similar manner to indicate that the utility could be found,
146       but not invoked. Some scripts produce meaningful error messages differ‐
147       entiating the 126 and 127 cases. The distinction between exit codes 126
148       and  127 is based on KornShell practice that uses 127 when all attempts
149       to exec the utility fail with [ENOENT], and uses 126 when  any  attempt
150       to exec the utility fails for any other reason.
151

EXAMPLES

153       It is frequently desirable to apply nohup to pipelines or lists of com‐
154       mands. This can be done by placing pipelines and  command  lists  in  a
155       single  file; this file can then be invoked as a utility, and the nohup
156       applies to everything in the file.
157
158       Alternatively, the following command can be used to apply  nohup  to  a
159       complex command:
160
161           nohup sh −c 'complex-command-line' </dev/null
162

RATIONALE

164       The 4.3 BSD version ignores SIGTERM and SIGHUP, and if ./nohup.out can‐
165       not be used, it fails instead of trying to use $HOME/nohup.out.
166
167       The csh utility has a built-in version of nohup that  acts  differently
168       from the nohup defined in this volume of POSIX.1‐2008.
169
170       The  term  utility  is used, rather than command, to highlight the fact
171       that shell compound commands, pipelines, special built-ins, and so  on,
172       cannot  be  used  directly.  However, utility includes user application
173       programs and shell scripts, not just the standard utilities.
174
175       Historical versions of the nohup  utility  use  default  file  creation
176       semantics. Some more recent versions use the permissions specified here
177       as an added security precaution.
178
179       Some historical implementations ignore SIGQUIT in addition  to  SIGHUP;
180       others  ignore SIGTERM. An early proposal allowed, but did not require,
181       SIGQUIT to be ignored. Several reviewers  objected  that  nohup  should
182       only  modify  the  handling  of  SIGHUP  as  required by this volume of
183       POSIX.1‐2008.
184
185       Historical versions of nohup did not affect standard  input,  but  that
186       causes  problems in the common scenario where the user logs into a sys‐
187       tem, types the command:
188
189           nohup make &
190
191       at the prompt, and then logs out. If standard input is not affected  by
192       nohup,  the  login session may not terminate for quite some time, since
193       standard input remains open until make exits. To  avoid  this  problem,
194       POSIX.1‐2008 allows implementations to redirect standard input if it is
195       a terminal. Since  the  behavior  is  implementation-defined,  portable
196       applications  that  may  run  into the problem should redirect standard
197       input themselves. For example, instead of:
198
199           nohup make &
200
201       an application can invoke:
202
203           nohup make </dev/null &
204

FUTURE DIRECTIONS

206       None.
207

SEE ALSO

209       Chapter 2, Shell Command Language, sh
210
211       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
212       Variables
213
214       The System Interfaces volume of POSIX.1‐2008, signal()
215
217       Portions  of  this text are reprinted and reproduced in electronic form
218       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
219       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
220       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
221       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
222       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
223       event of any discrepancy between this version and the original IEEE and
224       The Open Group Standard, the original IEEE and The Open Group  Standard
225       is  the  referee document. The original Standard can be obtained online
226       at http://www.unix.org/online.html .
227
228       Any typographical or formatting errors that appear  in  this  page  are
229       most likely to have been introduced during the conversion of the source
230       files to man page format. To report such errors,  see  https://www.ker
231       nel.org/doc/man-pages/reporting_bugs.html .
232
233
234
235IEEE/The Open Group                  2013                            NOHUP(1P)
Impressum