Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / nohup.1
blob50c936a47419b2d40284943662564273d0d7d17b
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
45 .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH NOHUP 1 "Oct 25, 2017"
48 .SH NAME
49 nohup \- run a command immune to hangups
50 .SH SYNOPSIS
51 .LP
52 .nf
53 \fB/usr/bin/nohup\fR \fIcommand\fR [\fIargument\fR]...
54 .fi
56 .SH DESCRIPTION
57 .sp
58 .LP
59 The \fBnohup\fR utility invokes the named \fIcommand\fR with the arguments
60 supplied.  When the \fIcommand\fR is invoked, \fBnohup\fR arranges for the
61 \fBSIGHUP\fR signal to be ignored by the process.
62 .sp
63 .LP
64 When invoked with the \fB-p\fR or \fB-g\fR flags, \fBnohup\fR arranges for
65 processes already running as identified by a list of process \fBID\fRs or a
66 list of process group \fBID\fRs to become immune to hangups.
67 .sp
68 .LP
69 The \fBnohup\fR utility can be used when it is known that \fIcommand\fR takes a
70 long time to run and the user wants to log out of the terminal. When a shell
71 exits, the system sends its children \fBSIGHUP\fR signals, which by default
72 cause them to be killed. All stopped, running, and background jobs ignores
73 \fBSIGHUP\fR and continue running, if their invocation is preceded by the
74 \fBnohup\fR command or if the process programmatically has chosen to ignore
75 \fBSIGHUP\fR.
76 .sp
77 .ne 2
78 .na
79 \fB\fB/usr/bin/nohup\fR\fR
80 .ad
81 .RS 27n
82 Processes run by \fB/usr/bin/nohup\fR are immune to \fBSIGHUP\fR.
83 .sp
84 The \fBnohup\fR utility does not arrange to make processes immune to a
85 \fBSIGTERM\fR (terminate) signal, so unless they arrange to be immune to
86 \fBSIGTERM\fR or the shell makes them immune to \fBSIGTERM\fR, they will
87 receive it.
88 .sp
89 If \fBnohup.out\fR is not writable in the current directory, output is
90 redirected to \fB$HOME/nohup.out\fR. If a file is created, the file has read
91 and write permission (\fB600\fR. See \fBchmod\fR(1). If the standard error is a
92 terminal, it is redirected to the standard output, otherwise it is not
93 redirected. The priority of the process run by \fBnohup\fR is not altered.
94 .RE
96 .SH OPTIONS
97 .sp
98 .LP
99 The following options are supported:
101 .ne 2
103 \fB\fB-a\fR\fR
105 .RS 6n
106 Always changes the signal disposition of target processes. This option is valid
107 only when specified with \fB-p\fR or \fB-g\fR.
111 .ne 2
113 \fB\fB-F\fR\fR
115 .RS 6n
116 Force. Grabs the target processes even if another process has control. This
117 option is valid only when specified with \fB-p\fR or \fB-g.\fR
121 .ne 2
123 \fB\fB-g\fR\fR
125 .RS 6n
126 Operates on a list of process groups. This option is not valid with \fB-p\fR.
130 .ne 2
132 \fB\fB-p\fR\fR
134 .RS 6n
135 Operates on a list of processes. This option is not valid with \fB-g\fR.
138 .SH OPERANDS
141 The following operands are supported:
143 .ne 2
145 \fB\fIpid\fR\fR
147 .RS 12n
148 A decimal process \fBID\fR to be manipulated by \fBnohup\fR \fB-p\fR.
152 .ne 2
154 \fB\fIpgid\fR\fR
156 .RS 12n
157 A decimal process group \fBID\fR to be manipulated by \fBnohup\fR \fB-g\fR.
161 .ne 2
163 \fB\fIcommand\fR\fR
165 .RS 12n
166 The name of a command that is to be invoked. If the \fIcommand\fR operand names
167 any of the special \fBshell_builtins\fR(1) utilities, the results are
168 undefined.
172 .ne 2
174 \fB\fIargument\fR\fR
176 .RS 12n
177 Any string to be supplied as an argument when invoking the \fIcommand\fR
178 operand.
181 .SH USAGE
184 Caution should be exercised when using the \fB-F\fR flag. Imposing two
185 controlling processes on one victim process can lead to chaos. Safety is
186 assured only if the primary controlling process, typically a debugger, has
187 stopped the victim process and the primary controlling process is doing nothing
188 at the moment of application of the \fBproc\fR tool in question.
189 .SH EXAMPLES
191 \fBExample 1 \fRApplying nohup to pipelines or command lists
194 It is frequently desirable to apply \fBnohup\fR to pipelines or lists of
195 commands. This can be done only by placing pipelines and command lists in a
196 single file, called a shell script. One can then issue:
199 .in +2
201 example$ \fBnohup sh \fIfile\fR\fR      
203 .in -2
208 and the \fBnohup\fR applies to everything in \fIfile\fR. If the shell script
209 \fIfile\fR is to be executed often, then the need to type \fBsh\fR can be
210 eliminated by giving \fIfile\fR execute permission.
214 Add an ampersand and the contents of \fIfile\fR are run in the background with
215 interrupts also ignored (see \fBsh\fR(1)):
218 .in +2
220 example$ \fBnohup \fIfile\fR &\fR
222 .in -2
226 \fBExample 2 \fRApplying nohup -p to a process
228 .in +2
230 example$ \fBlong_running_command &\fR
231 example$ \fBnohup -p `pgrep long_running_command`\fR
233 .in -2
237 \fBExample 3 \fRApplying nohup -g to a process group
239 .in +2
241 example$ \fBmake &\fR
242 example$ \fBps -o sid -p $$\fR
243    SID
244 81079
245 example$ \fBnohup -g `pgrep -s 81079 make`\fR
247 .in -2
250 .SH ENVIRONMENT VARIABLES
253 See \fBenviron\fR(5) for descriptions of the following environment variables
254 that affect the execution of \fBnohup\fR: \fBLANG\fR, \fBLC_ALL\fR,
255 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBPATH\fR, \fBNLSPATH\fR, and \fBPATH\fR.
257 .ne 2
259 \fB\fBHOME\fR\fR
261 .RS 8n
262 Determine the path name of the user's home directory: if the output file
263 \fBnohup.out\fR cannot be created in the current directory, the \fBnohup\fR
264 command uses the directory named by \fBHOME\fR to create the file.
267 .SH EXIT STATUS
270 The following exit values are returned:
272 .ne 2
274 \fB\fB126\fR\fR
276 .RS 7n
277 \fIcommand\fR was found but could not be invoked.
281 .ne 2
283 \fB\fB127\fR\fR
285 .RS 7n
286 An error occurred in \fBnohup\fR, or \fIcommand\fR could not be found
291 Otherwise, the exit values of \fBnohup\fR are those of the \fIcommand\fR
292 operand.
293 .SH FILES
295 .ne 2
297 \fB\fBnohup.out\fR\fR
299 .RS 19n
300 The output file of the \fBnohup\fR execution if standard output is a terminal
301 and if the current directory is writable.
305 .ne 2
307 \fB\fB$HOME/nohup.out\fR\fR
309 .RS 19n
310 The output file of the \fBnohup\fR execution if standard output is a terminal
311 and if the current directory is not writable.
314 .SH ATTRIBUTES
317 See \fBattributes\fR(5) for descriptions of the following attributes:
318 .SS "/usr/bin/nohup"
323 box;
324 c | c
325 l | l .
326 ATTRIBUTE TYPE  ATTRIBUTE VALUE
328 CSI     Enabled
330 Interface Stability     Standard
333 .SH SEE ALSO
336 \fBbatch\fR(1), \fBchmod\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBnice\fR(1),
337 \fBpgrep\fR(1), \fBproc\fR(1), \fBps\fR(1), \fBsh\fR(1),
338 \fBshell_builtins\fR(1), \fBsignal\fR(3C), \fBproc\fR(4), \fBattributes\fR(5),
339 \fBenviron\fR(5), \fBstandards\fR(5)
340 .SH WARNINGS
343 If you are running the Korn shell (\fBksh\fR(1)) as your login shell, and have
344 \fBnohup\fR'ed jobs running when you attempt to log out, you are warned with
345 the message:
347 .in +2
349 You have jobs running.
351 .in -2
356 You need to log out a second time to actually log out. However, your background
357 jobs continues to run.
358 .SH NOTES
361 The C-shell (\fBcsh\fR(1)) has a built-in command \fBnohup\fR that provides
362 immunity from \fBSIGHUP\fR, but does not redirect output to \fBnohup.out\fR.
363 Commands executed with `\fB&\fR\&' are automatically immune to \fBHUP\fR
364 signals while in the background.
367 \fBnohup\fR does not recognize command sequences. In the case of the following
368 command,
370 .in +2
372 example$ \fBnohup command1; command2\fR
374 .in -2
379 the \fBnohup\fR utility applies only to \fBcommand1\fR. The command,
381 .in +2
383 example$ \fBnohup (command1; command2)\fR
385 .in -2
390 is syntactically incorrect.