nohup executes a command or shell script, ignoring the signals SIGHUP (signal number 1) and SIGQUIT (signal number 3). nohup can be used to prevent a process from being terminated when you log out from a terminal.
Before the call
If you wish to use nohup with a pipe or a list of commands, you must put the relevant pipeline or command list in a file and run the file as a shell script under nohup’s management.
Syntax
nohup command[ argument...] |
Any command or shell script. You can pass arguments to command by entering them after the command as usual. If the standard output and standard error of command have not been redirected, they will be written to a file called nohup.out in the current directory. If you are not permitted to create the file nohup.out in the current directory (i.e. you have no write permission for this directory) or if you do not have write permission for the file nohup.out in the current directory, the output will be redirected to the file $HOME/nohup.out. If the file nohup.out or $HOME/nohup.out does not exist, a corresponding file is created and the file’s permission bits will be set only for the calling user; otherwise, the output is appended to the existing file. |
Exit status
126 | The utility specified by command was found but could not be invoked. |
127 | An error occured in the nohup utility or the utility specified by command could not be found. |
Error
You are not allowed to create a file called nohup.out in the current working directory or in $HOME, or you are not allowed to write to existing nohup.out files in those directories. |
File
nohup.out File located in the current directory which receives the standard output and standard error $HOME/nohup.out The standard output and standard error output of commands executed under nohup are sent to this file if the nohup.out file in the current directory is write-protected or if you are not allowed to create this file in the current directory (because you do not have write permission there). |
Variable
HOME The value of the environment variable HOME is used to determine the directory in which the file nohup.out is to be created in cases where nohup.out in the current directory is write-protected or where you are not allowed to create files in the current directory. PATH Determine the search path that will be used to locate the utility invoked. |
Locale
The following environment variables affect the execution of du: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example
You initiate the following job and set it to run in the background:
You then log out. program is not terminated, since it is immune to the quit signal. The output is written to a file called nohup.out. |
See also
chmod, kill, nice, sh |