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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
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.
47 .TH NOHUP 1 "Oct 25, 2017"
49 nohup \- run a command immune to hangups
53 \fB/usr/bin/nohup\fR \fIcommand\fR [\fIargument\fR]...
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.
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.
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
79 \fB\fB/usr/bin/nohup\fR\fR
82 Processes run by \fB/usr/bin/nohup\fR are immune to \fBSIGHUP\fR.
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
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.
99 The following options are supported:
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.
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
126 Operates on a list of process groups. This option is not valid with \fB-p\fR.
135 Operates on a list of processes. This option is not valid with \fB-g\fR.
141 The following operands are supported:
148 A decimal process \fBID\fR to be manipulated by \fBnohup\fR \fB-p\fR.
157 A decimal process group \fBID\fR to be manipulated by \fBnohup\fR \fB-g\fR.
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
177 Any string to be supplied as an argument when invoking the \fIcommand\fR
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.
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:
201 example$ \fBnohup sh \fIfile\fR\fR
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)):
220 example$ \fBnohup \fIfile\fR &\fR
226 \fBExample 2 \fRApplying nohup -p to a process
230 example$ \fBlong_running_command &\fR
231 example$ \fBnohup -p `pgrep long_running_command`\fR
237 \fBExample 3 \fRApplying nohup -g to a process group
241 example$ \fBmake &\fR
242 example$ \fBps -o sid -p $$\fR
245 example$ \fBnohup -g `pgrep -s 81079 make`\fR
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.
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.
270 The following exit values are returned:
277 \fIcommand\fR was found but could not be invoked.
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
297 \fB\fBnohup.out\fR\fR
300 The output file of the \fBnohup\fR execution if standard output is a terminal
301 and if the current directory is writable.
307 \fB\fB$HOME/nohup.out\fR\fR
310 The output file of the \fBnohup\fR execution if standard output is a terminal
311 and if the current directory is not writable.
317 See \fBattributes\fR(5) for descriptions of the following attributes:
326 ATTRIBUTE TYPE ATTRIBUTE VALUE
330 Interface Stability Standard
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)
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
349 You have jobs running.
356 You need to log out a second time to actually log out. However, your background
357 jobs continues to run.
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
372 example$ \fBnohup command1; command2\fR
379 the \fBnohup\fR utility applies only to \fBcommand1\fR. The command,
383 example$ \fBnohup (command1; command2)\fR
390 is syntactically incorrect.