Nohup

From Christoph's Personal Wiki
Revision as of 23:20, 3 November 2006 by Christoph (Talk | contribs) (See also)

Jump to: navigation, search
The correct title of this article is nohup. The initial letter is capitalized due to technical restrictions.

nohup is a command that is used to run another command while suppressing the action of the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. It is most often used to run commands in background as daemons. Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected.

Description

nohup runs the given COMMAND with hangup signals ignored, so that the command can continue running in the background after you log out.

Synopsis

nohup COMMAND [ARG]...

If standard input is a terminal, it is redirected from /dev/null so that terminal sessions do not mistakenly consider the terminal to be used by the command. This is a GNU extension; programs intended to be portable to non-GNU hosts should use nohup COMMAND [ARG]... </dev/null instead.

If standard output is a terminal, the command's standard output is appended to the file nohup.out; if that cannot be written to, it is appended to the file $HOME/nohup.out; and if that cannot be written to, the command is not run. Any nohup.out or $HOME/nohup.out file created by nohup is made readable and writable only to the user, regardless of the current umask settings.

If standard error is a terminal, it is redirected to the same file descriptor as the (possibly-redirected) standard output.

nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an &. Also, nohup does not alter the niceness of COMMAND; use nice for that (eg, nohup nice COMMAND).

COMMAND must not be a special built-in utility (see: "Special built-in utilities" in info).

The only options are --help and --version. Note: Options must precede operands (see: "Common options" in info).

Exit status

126 
if COMMAND is found but cannot be invoked
127 
if nohup itself fails or if COMMAND can not be found the exit status of COMMAND otherwise

Example

The first of the commands below starts the program abcd in the background in such a way that the subsequent log out does not stop it.

% nohup abcd &
% exit

Existing jobs

Some shells (e.g. bash) provide a "shell builtin" that may be used to prevent SIGHUP being sent to existing jobs, even if they were not started with nohup. The bash name for this builtin is nohup.

See also

Linux command line programs
File and file system management: cat | cd | chmod | chown | chgrp | umask | cp | du | df | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rcp | rm | rmdir | split | touch | tree
Process management: anacron | at | chroot | cron/crontab | kill | nice | ps | sleep | screen | time | timex | top | nice/renice | wait
User Management/Environment: env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | wall | who | write
Text processing: awk | cut | diff | ex | head | tac | tee | iconv | join | less | more | paste | sed | sort | tail | tr | uniq | wc | xargs | perl
Shell programming: echo | expr | unset Printing: lp
Communications:
inetd | netstat | ping | rlogin | traceroute
Searching:

find | grep/egrep/fgrep | strings

Miscellaneous:

banner | bc | cal | man | yes