2 .\" Copyright 1989 AT&T Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions 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.opengroup.org/unix/online.html.
6 .\" This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH NOHUP 1 "Jun 19, 2006"
12 nohup \- run a command immune to hangups
16 \fB/usr/bin/nohup\fR \fIcommand\fR [\fIargument\fR]...
21 \fB/usr/bin/nohup\fR \fB-p\fR [\fB-Fa\fR] \fIpid\fR [\fIpid\fR]...
26 \fB/usr/bin/nohup\fR \fB-g\fR [\fB-Fa\fR] \fIgpid\fR [\fIgpid\fR]...
31 \fB/usr/xpg4/bin/nohup\fR \fIcommand\fR [\fIargument\fR]...
37 The \fBnohup\fR utility invokes the named \fIcommand\fR with the arguments
38 supplied. When the \fIcommand\fR is invoked, \fBnohup\fR arranges for the
39 \fBSIGHUP\fR signal to be ignored by the process.
42 When invoked with the \fB-p\fR or \fB-g\fR flags, \fBnohup\fR arranges for
43 processes already running as identified by a list of process \fBID\fRs or a
44 list of process group \fBID\fRs to become immune to hangups.
47 The \fBnohup\fR utility can be used when it is known that \fIcommand\fR takes a
48 long time to run and the user wants to log out of the terminal. When a shell
49 exits, the system sends its children \fBSIGHUP\fR signals, which by default
50 cause them to be killed. All stopped, running, and background jobs ignores
51 \fBSIGHUP\fR and continue running, if their invocation is preceded by the
52 \fBnohup\fR command or if the process programmatically has chosen to ignore
57 \fB\fB/usr/bin/nohup\fR\fR
60 Processes run by \fB/usr/bin/nohup\fR are immune to \fBSIGHUP\fR (hangup) and
61 \fBSIGQUIT\fR (quit) signals.
67 \fB\fB/usr/bin/nohup\fR \fB-p\fR [\fB-Fa\fR]\fR
70 Processes specified by \fBID\fR are made immune to \fBSIGHUP\fR and
71 \fBSIGQUIT\fR, and all output to the controlling terminal is redirected to
72 \fBnohup.out\fR. If \fB-F\fR is specified, \fBnohup\fR forces control of each
73 process. If \fB-a\fR is specified, \fBnohup\fR changes the signal disposition
74 of \fBSIGHUP\fR and \fBSIGQUIT\fR even if the process has installed a handler
81 \fB\fB/usr/bin/nohup\fR \fB-g\fR [\fB-Fa\fR]\fR
84 Every process in the same process group as the processes specified by \fBID\fR
85 are made immune to \fBSIGHUP\fR and \fBSIGQUIT\fR, and all output to the
86 controlling terminal is redirected to \fBnohup.out\fR. If \fB-F\fR is
87 specified, \fBnohup\fR forces control of each process. If \fB-a\fR is
88 specified, \fBnohup\fR changes the signal disposition of \fBSIGHUP\fR and
89 \fBSIGQUIT\fR even if the process has installed a handler for either signal.
95 \fB\fB/usr/xpg4/bin/nohup\fR\fR
98 Processes run by \fB/usr/xpg4/bin/nohup\fR are immune to \fBSIGHUP\fR.
100 The \fBnohup\fR utility does not arrange to make processes immune to a
101 \fBSIGTERM\fR (terminate) signal, so unless they arrange to be immune to
102 \fBSIGTERM\fR or the shell makes them immune to \fBSIGTERM\fR, they will
105 If \fBnohup.out\fR is not writable in the current directory, output is
106 redirected to \fB$HOME/nohup.out\fR. If a file is created, the file has read
107 and write permission (\fB600\fR. See \fBchmod\fR(1). If the standard error is a
108 terminal, it is redirected to the standard output, otherwise it is not
109 redirected. The priority of the process run by \fBnohup\fR is not altered.
115 The following options are supported:
122 Always changes the signal disposition of target processes. This option is valid
123 only when specified with \fB-p\fR or \fB-g\fR.
132 Force. Grabs the target processes even if another process has control. This
133 option is valid only when specified with \fB-p\fR or \fB-g.\fR
142 Operates on a list of process groups. This option is not valid with \fB-p\fR.
151 Operates on a list of processes. This option is not valid with \fB-g\fR.
157 The following operands are supported:
164 A decimal process \fBID\fR to be manipulated by \fBnohup\fR \fB-p\fR.
173 A decimal process group \fBID\fR to be manipulated by \fBnohup\fR \fB-g\fR.
182 The name of a command that is to be invoked. If the \fIcommand\fR operand names
183 any of the special \fBshell_builtins\fR(1) utilities, the results are
193 Any string to be supplied as an argument when invoking the \fIcommand\fR
200 Caution should be exercised when using the \fB-F\fR flag. Imposing two
201 controlling processes on one victim process can lead to chaos. Safety is
202 assured only if the primary controlling process, typically a debugger, has
203 stopped the victim process and the primary controlling process is doing nothing
204 at the moment of application of the \fBproc\fR tool in question.
207 \fBExample 1 \fRApplying nohup to pipelines or command lists
210 It is frequently desirable to apply \fBnohup\fR to pipelines or lists of
211 commands. This can be done only by placing pipelines and command lists in a
212 single file, called a shell script. One can then issue:
217 example$ \fBnohup sh \fIfile\fR\fR
224 and the \fBnohup\fR applies to everything in \fIfile\fR. If the shell script
225 \fIfile\fR is to be executed often, then the need to type \fBsh\fR can be
226 eliminated by giving \fIfile\fR execute permission.
230 Add an ampersand and the contents of \fIfile\fR are run in the background with
231 interrupts also ignored (see \fBsh\fR(1)):
236 example$ \fBnohup \fIfile\fR &\fR
242 \fBExample 2 \fRApplying nohup -p to a process
246 example$ \fBlong_running_command &\fR
247 example$ \fBnohup -p `pgrep long_running_command`\fR
253 \fBExample 3 \fRApplying nohup -g to a process group
257 example$ \fBmake &\fR
258 example$ \fBps -o sid -p $$\fR
261 example$ \fBnohup -g `pgrep -s 81079 make`\fR
266 .SH ENVIRONMENT VARIABLES
269 See \fBenviron\fR(5) for descriptions of the following environment variables
270 that affect the execution of \fBnohup\fR: \fBLANG\fR, \fBLC_ALL\fR,
271 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBPATH\fR, \fBNLSPATH\fR, and \fBPATH\fR.
278 Determine the path name of the user's home directory: if the output file
279 \fBnohup.out\fR cannot be created in the current directory, the \fBnohup\fR
280 command uses the directory named by \fBHOME\fR to create the file.
286 The following exit values are returned:
293 \fIcommand\fR was found but could not be invoked.
302 An error occurred in \fBnohup\fR, or \fIcommand\fR could not be found
307 Otherwise, the exit values of \fBnohup\fR are those of the \fIcommand\fR
313 \fB\fBnohup.out\fR\fR
316 The output file of the \fBnohup\fR execution if standard output is a terminal
317 and if the current directory is writable.
323 \fB\fB$HOME/nohup.out\fR\fR
326 The output file of the \fBnohup\fR execution if standard output is a terminal
327 and if the current directory is not writable.
333 See \fBattributes\fR(5) for descriptions of the following attributes:
342 ATTRIBUTE TYPE ATTRIBUTE VALUE
347 .SS "/usr/xpg4/bin/nohup"
355 ATTRIBUTE TYPE ATTRIBUTE VALUE
359 Interface Stability Standard
365 \fBbatch\fR(1), \fBchmod\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBnice\fR(1),
366 \fBpgrep\fR(1), \fBproc\fR(1), \fBps\fR(1), \fBsh\fR(1),
367 \fBshell_builtins\fR(1), \fBsignal\fR(3C), \fBproc\fR(4), \fBattributes\fR(5),
368 \fBenviron\fR(5), \fBstandards\fR(5)
372 If you are running the Korn shell (\fBksh\fR(1)) as your login shell, and have
373 \fBnohup\fR'ed jobs running when you attempt to log out, you are warned with
378 You have jobs running.
385 You need to log out a second time to actually log out. However, your background
386 jobs continues to run.
390 The C-shell (\fBcsh\fR(1)) has a built-in command \fBnohup\fR that provides
391 immunity from \fBSIGHUP\fR, but does not redirect output to \fBnohup.out\fR.
392 Commands executed with `\fB&\fR\&' are automatically immune to \fBHUP\fR
393 signals while in the background.
396 \fBnohup\fR does not recognize command sequences. In the case of the following
401 example$ \fBnohup command1; command2\fR
408 the \fBnohup\fR utility applies only to \fBcommand1\fR. The command,
412 example$ \fBnohup (command1; command2)\fR
419 is syntactically incorrect.