nohup Command


Runs a command without hangups.


nohup { -p pid | CommandArg ... ] [ & ] }


The nohup command runs the command specified by the Command parameter and any related Arg parameters, ignoring all hang up signals (SIGHUP) or modifies the process specified with the -p option to ignore all SIGHUP signals. SIGHUP is a signal that is sent to a process when the controlling terminal of the process is closed.

The nohup command can also be used to run programs in the background after logging off. To run a nohup command in the background, add an & (ampersand) to the end of the command.

If the standard error is displayed on the terminal and if the standard output is neither displayed on the terminal, nor sent to the output file specified by the user (the default output file is nohup.out), both the ./nohup.out and $HOME/nohup.out files are not created or opened for appending the error message. The nohup command does not execute the parameter utility that is specified with the nohup command and exits with exit status 127.
Note: The -p pid and Command options can not be specified together.
When the -p pid flag is used, the output of the specified process will not be re-directed to the nohup.out file.


Item Description
-p pid pid is the process-id of a running process. The nohup command modifies the specified process, to ignore all hangup (SIGHUP) signals.

Exit Status

This command returns the following exit values:

Item Description
126 The command specified by the Command parameter was found but could not be invoked.
127 An error occurred in the nohup command or the command specified by the Command parameter could not be found.

Otherwise, the exit status of the nohup command is that of the command specified by the Command parameter.


  1. To run a command in the background after you log off, enter:
    $ nohup find / -print &
    After you enter this command, the following is displayed:
    $ Sending output to nohup.out
    The process ID number changes to that of the background process started by & (ampersand). The message Sending output to nohup.out informs you that the output from the find / -print command is in the nohup.out file. You can log off after you see these messages, even if the find command is still running.
  2. To run a command in the background and redirect the standard output to a different file, enter:
    $ nohup find / -print >filenames &
    This example runs the find / -print command and stores its output in a file named filenames. Now only the process ID and prompt are displayed:
    Wait before logging off because thenohup command takes a moment to start the command specified by the Command parameter. If you log off too quickly, the command specified by the Command parameter may not run at all. Once the command specified by the Command parameter starts, logging off does not affect it.
  3. To run more than one command, use a shell procedure. For example, if you write the shell procedure:
    neqn math1 | nroff > fmath1
    and name it the nnfmath1 file, you can run the nohup command for all of the commands in the nnfmath1 file with the command:
    nohup sh nnfmath1
  4. If you assign execute permission to the nnfmath1 file, you get the same results by issuing the command:
    nohup nnfmath1
  5. To run the nnfmath1 file in the background, enter:
    nohup nnfmath1  
  6. To run the nnfmath1 file in the Korn shell, enter:
    nohup ksh nnfmath1
  7. To make a running process ignore all hangup signals, enter:
    nohup -p 161792