NOHUP(1P)
β¨ PROLOG β¨
okay bestie, quick heads up before we dive in π this page is part of the POSIX Programmer's Manual. So like, the Linux implementation of this interface might be different (go check the matching Linux manual page for the tea on Linux behavior), or honestly it might not even be implemented on Linux at all. π
π¦ NAME π¦
nohup β the way it invokes a utility that's immune to hangups π
πΈ SYNOPSIS πΈ
nohup utility [argument...]
π DESCRIPTION π
okay so here's the vibe: nohup invokes the utility named by the utility operand, and it passes along whatever you gave it as the argument operands. β¨ At the exact moment the named utility gets invoked, the SIGHUP signal shall be set to be ignored. That's literally the whole point, bestie β hangups can't touch you. π
If standard input is associated with a terminal, nohup may redirect standard input from an unspecified file. (iykyk β "unspecified" is doing a lot of heavy lifting there. π)
If standard output is a terminal, all output the named utility writes 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, then the output shall be appended to the end of the file nohup.out in the directory specified by the HOME environment variable. And if neither file can be created or opened for appending, then utility shall not be invoked at all. periodt. If a file does get created, its permission bits shall be set to S_IRUSR | S_IWUSR. π
Now, if standard error is a terminal and standard output is open but is not a terminal, all output the named utility writes to its standard error shall be redirected to the same open file description as the standard output. But if standard error is a terminal and standard output either is a terminal or is closed, that same output shall instead be appended to the end of the nohup.out file as described above. π
π OPTIONS π
None. Not a single one. no flags, no crumbs. π
π OPERANDS π
The following operands shall be supported, bestie:
- utility β the name of a utility that is to be invoked. If the utility operand names any of the special built-in utilities in Section 2.14, Special Built-In Utilities, the results are undefined. π (so like... don't.)
- argument β any string to be supplied as an argument when invoking the utility named by the utility operand.
π§ STDIN π§
Not used. β¨
π«Ά INPUT FILES π«Ά
None. π
β ENVIRONMENT VARIABLES β
The following environment variables shall affect the execution of nohup:
HOMEβ determines the pathname of the user's home directory: if the output filenohup.outcannot be created in the current directory, thenohuputility shall use the directory named byHOMEto create the file. πLANGβ provides a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) πLC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables. she's the boss fr fr πLC_CTYPEβ determines 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β determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error. π¬NLSPATHβ determines the location of message catalogs for the processing ofLC_MESSAGES. πPATHβ determines the search path that is used to locate the utility to be invoked. See the Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables. π£οΈ
π ASYNCHRONOUS EVENTS π
The nohup utility shall take the standard action for all signals β except that SIGHUP shall be ignored. that's the one exception, and it's iconic. π
π« STDOUT π«
If 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 operands. Otherwise, nothing shall be written to the standard output. π€«
π₯ STDERR π₯
If standard output is a terminal, a message shall be written to standard error, indicating the name of the file to which the output is being appended. That file name shall be either nohup.out or $HOME/nohup.out. π
πΈ OUTPUT FILES πΈ
Output written by the named utility is appended to the file nohup.out (or $HOME/nohup.out), if the conditions hold as described in the DESCRIPTION. π
π¦ EXTENDED DESCRIPTION π¦
None. nothing here, moving on bestie β¨
π 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 thenohuputility, 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. (as in, the standard default behavior, not "default" like a personality trait. π)
The following sections are informative. (translation: vibes and lore, not requirements. β¨)
π APPLICATION USAGE π
okay so here's some lore you're gonna wanna know: 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 tell the difference between "failure to find a utility" and "invoked utility exited with an error indication". π§
Why 127 specifically? Because it's not commonly used for other meanings β most utilities use small values for "normal error conditions", and values above 128 can get confused with termination due to receipt of a signal. π
The value 126 was chosen in a similar manner, to indicate that the utility could be found, but not invoked. Some scripts produce meaningful error messages differentiating the 126 and 127 cases. π―
And the distinction between exit codes 126 and 127 is based on KornShell practice, which 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 reason. no cap. π―
π EXAMPLES π
It is frequently desirable to apply nohup to pipelines or lists of commands. You can do this by placing pipelines and command lists in a single file; that 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' </dev/null
π§ RATIONALE π§
okay gather round, history time π
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 POSIX.1β2017. π
The term utility is used, rather than command, to highlight the fact that shell compound commands, pipelines, special built-ins, and so on, cannot be used directly. However, utility does include 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 precaution. π
Some historical implementations ignore SIGQUIT in addition 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 POSIX.1β2017. π£οΈ
Historical versions of nohup did not affect standard input, but that causes problems in the common scenario where the user logs into a system, types the command:
nohup make &
at the prompt, and then logs out. If standard input is not affected by nohup, the login session may not terminate for quite some time, since standard input remains open until make exits. π To avoid this problem, POSIX.1β2008 allows implementations to redirect standard input if it is a terminal. Since the behavior is implementation-defined, portable applications that may run into the problem should redirect standard input themselves. For example, instead of:
nohup make &
an application can invoke:
nohup make </dev/null &
π FUTURE DIRECTIONS π
None. the future is... nothing. slay. π
π SEE ALSO π
- Chapter 2, Shell Command Language,
sh - The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables
- The System Interfaces volume of POSIX.1β2017,
signal()
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute 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.opengroup.org/unix/online.html . π
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . π
okay that's the whole page bestie, you ate that π
β¨ this was IEEE/The Open Group, 2017, and the page is NOHUP(1P) β mwah, go forth and nohup responsibly π«Άπ
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms