Previous | Table of Contents | Next |
DESCRIPTION
The external nohup command executes a UNIX command immune to the hang-up and quit signals; thus its name no h ang- up. The primary objective of the nohup command is to have a process continue executing if you get logged off the system because of a terminal line hang-up.
| |
C shell | |
---|---|
The nohup command in C shell is a built-in command. This internal command does not redirect output to the nohup.out file like its System V counterpart . | |
Any command ending with an &, which places the process in background mode, is automatically immune to hang-up signals. | |
|
COMMAND FORMAT
Following is the general format of the nohup command.
nohup command [ options arguments ]
Arguments
The following arguments may be passed to the nohup command.
command | The command you wish to execute which will not terminate if a hang-up or quit signal is received. |
options | The options for the command |
arguments | The arguments for the command |
FURTHER DISCUSSION
The nohup command allows you to start a job and then log off the system. The job continues running even though a hang-up signal was sent to it. The standard output and standard error of nohup and your command are redirected to the file nohup.out. If nohup cannot create nohup.out, then it tries to write to $HOME/nohup.out. You can redirect the output by specifying the output file. For example,
cj> nohup acmd 2>&1 > acmd.out &
executes the acmd in background, ignoring hang-up and quit signals. The output is sent to the acmd.out file.
If you want the nohup command to apply to several commands, you must write a shell script containing the desired commands. For example,
cj> cat sortdata for FILE in data1 data2 data3 data4 do sort $FILE -o $FILE done
The sortdata shell script sorts each file named data1 through data4 . To run this script in background without terminating when you log off the system, you type
cj> nohup sortdata &
You must be careful in applying the nohup command to commands on the shell command line. For example,
cj> nohup command1; command2
nohups the first command but not the second.
If the following command is specified on the command line, the shell will complain about the syntax. You cannot specify subshell process as another command s arguments.
cj> nohup ( command1 )
APPLICATIONS
You usually use the nohup command to start long jobs and then log off the system. It can be used for jobs you want to execute and make certain they are not terminated if you are logged off the system or if a quit signal is received.
TYPICAL OPERATION
In this activity you use the nohup command to start a job in background, log off the system, log back in, and check on the process. Begin at the shell prompt.
Previous | Table of Contents | Next |