1nohup(1)                         User Commands                        nohup(1)
2
3
4

NAME

6       nohup - run a command immune to hangups
7

SYNOPSIS

9       /usr/bin/nohup command [argument]...
10
11
12       /usr/bin/nohup -p [-Fa] pid [pid]...
13
14
15       /usr/bin/nohup -g [-Fa] gpid [gpid]...
16
17
18       /usr/xpg4/bin/nohup command [argument]...
19
20

DESCRIPTION

22       The  nohup  utility  invokes  the named command with the arguments sup‐
23       plied.  When the command is invoked, nohup arranges for the SIGHUP sig‐
24       nal to be ignored by the process.
25
26
27       When  invoked  with  the  -p  or -g flags, nohup arranges for processes
28       already running as identified by a list of process IDs  or  a  list  of
29       process group IDs to become immune to hangups.
30
31
32       The  nohup  utility  can  be used when it is known that command takes a
33       long time to run and the user wants to log out of the terminal. When  a
34       shell  exits,  the  system  sends its children SIGHUP signals, which by
35       default cause them to be killed. All stopped, running,  and  background
36       jobs  ignores  SIGHUP and continue running, if their invocation is pre‐
37       ceded by the nohup command or if the process programmatically has  cho‐
38       sen to ignore SIGHUP.
39
40       /usr/bin/nohup             Processes  run  by /usr/bin/nohup are immune
41                                  to SIGHUP (hangup) and SIGQUIT  (quit)  sig‐
42                                  nals.
43
44
45       /usr/bin/nohup -p [-Fa]    Processes specified by ID are made immune to
46                                  SIGHUP and SIGQUIT, and all  output  to  the
47                                  controlling   terminal   is   redirected  to
48                                  nohup.out. If -F is specified, nohup  forces
49                                  control of each process. If -a is specified,
50                                  nohup  changes  the  signal  disposition  of
51                                  SIGHUP  and  SIGQUIT even if the process has
52                                  installed a handler for either signal.
53
54
55       /usr/bin/nohup -g [-Fa]    Every process in the same process  group  as
56                                  the  processes  specified  by  ID  are  made
57                                  immune to SIGHUP and SIGQUIT, and all output
58                                  to the controlling terminal is redirected to
59                                  nohup.out. If -F is specified, nohup  forces
60                                  control of each process. If -a is specified,
61                                  nohup  changes  the  signal  disposition  of
62                                  SIGHUP  and  SIGQUIT even if the process has
63                                  installed a handler for either signal.
64
65
66       /usr/xpg4/bin/nohup        Processes  run  by  /usr/xpg4/bin/nohup  are
67                                  immune to SIGHUP.
68
69                                  The  nohup  utility does not arrange to make
70                                  processes immune to  a  SIGTERM  (terminate)
71                                  signal,  so unless they arrange to be immune
72                                  to SIGTERM or the shell makes them immune to
73                                  SIGTERM, they will receive it.
74
75                                  If  nohup.out is not writable in the current
76                                  directory,   output   is    redirected    to
77                                  $HOME/nohup.out.  If  a file is created, the
78                                  file has read and write permission (600. See
79                                  chmod(1).  If the standard error is a termi‐
80                                  nal, it is redirected to the  standard  out‐
81                                  put,  otherwise  it  is  not redirected. The
82                                  priority of the process run by nohup is  not
83                                  altered.
84
85

OPTIONS

87       The following options are supported:
88
89       -a    Always  changes  the signal disposition of target processes. This
90             option is valid only when specified with -p or -g.
91
92
93       -F    Force. Grabs the target processes even  if  another  process  has
94             control. This option is valid only when specified with -p or -g.
95
96
97       -g    Operates  on  a  list of process groups. This option is not valid
98             with -p.
99
100
101       -p    Operates on a list of processes. This option is  not  valid  with
102             -g.
103
104

OPERANDS

106       The following operands are supported:
107
108       pid         A decimal process ID to be manipulated by nohup -p.
109
110
111       pgid        A decimal process group ID to be manipulated by nohup -g.
112
113
114       command     The name of a command that is to be invoked. If the command
115                   operand names any of the special  shell_builtins(1)  utili‐
116                   ties, the results are undefined.
117
118
119       argument    Any  string to be supplied as an argument when invoking the
120                   command operand.
121
122

USAGE

124       Caution should be exercised when using the -F flag. Imposing  two  con‐
125       trolling  processes  on one victim process can lead to chaos. Safety is
126       assured only if the primary controlling process, typically a  debugger,
127       has  stopped  the victim process and the primary controlling process is
128       doing nothing at the moment of application of the proc  tool  in  ques‐
129       tion.
130

EXAMPLES

132       Example 1 Applying nohup to pipelines or command lists
133
134
135       It is frequently desirable to apply nohup to pipelines or lists of com‐
136       mands. This can be done only by placing pipelines and command lists  in
137       a single file, called a shell script. One can then issue:
138
139
140         example$ nohup sh file
141
142
143
144
145       and  the  nohup applies to everything in file. If the shell script file
146       is to be executed often, then the need to type sh can be eliminated  by
147       giving file execute permission.
148
149
150
151       Add  an  ampersand  and  the contents of file are run in the background
152       with interrupts also ignored (see sh(1)):
153
154
155         example$ nohup file &
156
157
158
159       Example 2 Applying nohup -p to a process
160
161         example$ long_running_command &
162         example$ nohup -p `pgrep long_running_command`
163
164
165
166       Example 3 Applying nohup -g to a process group
167
168         example$ make &
169         example$ ps -o sid -p $$
170            SID
171         81079
172         example$ nohup -g `pgrep -s 81079 make`
173
174
175

ENVIRONMENT VARIABLES

177       See environ(5) for descriptions of the following environment  variables
178       that  affect  the  execution  of nohup: LANG, LC_ALL, LC_CTYPE, LC_MES‐
179       SAGES, PATH, NLSPATH, and PATH.
180
181       HOME    Determine the path name of the user's home  directory:  if  the
182               output  file  nohup.out cannot be created in the current direc‐
183               tory, the nohup command uses the directory  named  by  HOME  to
184               create the file.
185
186

EXIT STATUS

188       The following exit values are returned:
189
190       126    command was found but could not be invoked.
191
192
193       127    An error occurred in nohup, or command could not be found
194
195
196
197       Otherwise, the exit values of nohup are those of the command operand.
198

FILES

200       nohup.out          The  output  file of the nohup execution if standard
201                          output is a terminal and if the current directory is
202                          writable.
203
204
205       $HOME/nohup.out    The  output  file of the nohup execution if standard
206                          output is a terminal and if the current directory is
207                          not writable.
208
209

ATTRIBUTES

211       See attributes(5) for descriptions of the following attributes:
212
213   /usr/bin/nohup
214       ┌─────────────────────────────┬─────────────────────────────┐
215       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
216       ├─────────────────────────────┼─────────────────────────────┤
217       │Availability                 │SUNWcsu                      │
218       ├─────────────────────────────┼─────────────────────────────┤
219       │CSI                          │Enabled                      │
220       └─────────────────────────────┴─────────────────────────────┘
221
222   /usr/xpg4/bin/nohup
223       ┌─────────────────────────────┬─────────────────────────────┐
224       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
225       ├─────────────────────────────┼─────────────────────────────┤
226       │Availability                 │SUNWxcu4                     │
227       ├─────────────────────────────┼─────────────────────────────┤
228       │CSI                          │Enabled                      │
229       ├─────────────────────────────┼─────────────────────────────┤
230       │Interface Stability          │Standard                     │
231       └─────────────────────────────┴─────────────────────────────┘
232

SEE ALSO

234       batch(1),  chmod(1), csh(1), ksh(1), nice(1), pgrep(1), proc(1), ps(1),
235       sh(1), shell_builtins(1),  signal(3C),  proc(4),  attributes(5),  envi‐
236       ron(5), standards(5)
237

WARNINGS

239       If  you  are  running  the Korn shell (ksh(1)) as your login shell, and
240       have nohup'ed jobs running when you attempt to log out, you are  warned
241       with the message:
242
243         You have jobs running.
244
245
246
247
248       You  need  to  log out a second time to actually log out. However, your
249       background jobs continues to run.
250

NOTES

252       The C-shell (csh(1)) has a built-in command nohup that  provides  immu‐
253       nity  from  SIGHUP, but does not redirect output to nohup.out. Commands
254       executed with `&' are automatically immune to HUP signals while in  the
255       background.
256
257
258       nohup  does not recognize command sequences. In the case of the follow‐
259       ing command,
260
261         example$ nohup command1; command2
262
263
264
265
266       the nohup utility applies only to command1. The command,
267
268         example$ nohup (command1; command2)
269
270
271
272
273       is syntactically incorrect.
274
275
276
277SunOS 5.11                        19 Jun 2006                         nohup(1)
Impressum