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

NAME

12       nohup — invoke a utility immune to hangups
13

SYNOPSIS

15       nohup utility [argument...]
16

DESCRIPTION

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

OPTIONS

42       None.
43

OPERANDS

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

STDIN

56       Not used.
57

INPUT FILES

59       None.
60

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

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

STDOUT

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

STDERR

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

OUTPUT FILES

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

EXTENDED DESCRIPTION

117       None.
118

EXIT STATUS

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

CONSEQUENCES OF ERRORS

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

APPLICATION USAGE

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

EXAMPLES

152       It is frequently desirable to apply nohup to pipelines or lists of com‐
153       mands. This can be done by placing pipelines and  command  lists  in  a
154       single  file; this file can then be invoked as a utility, and the nohup
155       applies to everything in the file.
156
157       Alternatively, the following command can be used to apply  nohup  to  a
158       complex command:
159
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‐2017.
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‐2017.
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
190           nohup make &
191
192       at the prompt, and then logs out. If standard input is not affected  by
193       nohup,  the  login session may not terminate for quite some time, since
194       standard input remains open until make exits. To  avoid  this  problem,
195       POSIX.1‐2008 allows implementations to redirect standard input if it is
196       a terminal. Since  the  behavior  is  implementation-defined,  portable
197       applications  that  may  run  into the problem should redirect standard
198       input themselves. For example, instead of:
199
200
201           nohup make &
202
203       an application can invoke:
204
205
206           nohup make </dev/null &
207

FUTURE DIRECTIONS

209       None.
210

SEE ALSO

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