Linux and Unix nohup command

About nohup

When using the command shell, prefixing a command with nohup prevents the command from being aborted if you log out or exit the shell.
The name nohup stands for “no hangup.” The hangup (HUP) signal, which is normally sent to a process to inform it that the user has logged off (or “hung up”), is intercepted by nohup, allowing the process to continue running.

 

Nohup syntax

nohup COMMAND [ARG]...
nohup OPTION...

Options

--help display a help message and exit.
--version output version information and exit.

If standard input is a terminal, nohup redirects it from /dev/null. If standard output is a terminal, append output to “nohup.out” if possible, “$HOME/nohup.out” otherwise. If standard error is a terminal, redirect it to standard output. To save output to file FILE, use “nohup COMMAND > FILE”.

Nohup examples

nohup find -size +100k > log.txt &
Run the find command, instructing it to search for any file bigger then 100 kilobytes. find will continue to search even if the user logs out, and write its results to the file log.txt.
The “&” symbol at the end of the command runs find in the background, returning you to the command prompt while it is running. It is normal to use nohup in conjunction with & if you want to continue running other commands.

Related commands

nice — Invoke a command with an altered scheduling priority.

Continue Reading