1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
nohup(P) nohup(P)
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 cre-
ated 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 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:
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 oper-
and.
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 direc-
tory: if the output file nohup.out cannot be cre-
ated 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 internationaliza-
tion variables that are unset or null. (See the
Base Definitions volume of IEEE Std 1003.1-2001,
Section 8.2, Internationalization Variables for
the precedence of internationalization variables
used to determine the values of locale cate-
gories.)
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 mes-
sages 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 Defini-
tions volume of IEEE Std 1003.1-2001, 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 oper-
ands. Otherwise, nothing shall be written to the stan-
dard 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
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 cre-
ated if it does not already exist.
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 simi-
lar 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 dis-
tinction 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 rea-
son.
EXAMPLES
It is frequently desirable to apply nohup to pipelines
or lists of commands. This can be done by placing pipe-
lines 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'
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 IEEE Std 1003.1-2001.
The term utility is used, rather than command, to high-
light 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 pre-
caution.
Some historical implementations ignore SIGQUIT in addi-
tion 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
IEEE Std 1003.1-2001.
FUTURE DIRECTIONS
None.
SEE ALSO
Shell Command Language , sh , the System Interfaces
volume of IEEE Std 1003.1-2001, signal()
COPYRIGHT
Portions of this text are reprinted and reproduced in
electronic form from IEEE Std 1003.1, 2003 Edition,
Standard for Information Technology -- Portable Operat-
ing System Interface (POSIX), The Open Group Base Speci-
fications Issue 6, Copyright (C) 2001-2003 by the Insti-
tute of Electrical and Electronics Engineers, Inc and
The Open Group. In the event of any discrepancy between
this version and the original IEEE and The Open Group
Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be
obtained online at http://www.open-
group.org/unix/online.html .
POSIX 2003 nohup(P)
|