Background Processing (using nohup)


There may be times when you want to start a command in the background on AIX and logout of the system without the command terminating. The nohup (no hang-up) command will keep your job alive after you logout.

The nohup command has the form:

nohup  command  [ Arg ... ]  [ & ]
By default the output from the command is appended to the file nohup.out in your current directory.


a) Running ls using nohup and in the background:

$ nohup ls &

The system responds by telling you about the process identifier, which is usually a multi-digit numeric. You are also informed that the output from the command will be sent to the file nohup.out.

b) Running several commands within a script using nohup

This process is similar to running a batch job on non-Unix computers. Insert the commands you want to run within a script (job file). For instance, if you want to run the AIX commands ls, sleep 60, pwd, and who sequentially, create a file called batchfile using your favourite editor and insert the following:

  ls                 # list directory contents
  sleep 60           # do nothing for 60 seconds
  pwd                # print working directory
  who                # see who's using the local system

If you wanted you could put all the commands on a single line within the file.

  ls; sleep 60; pwd; who 
Semi-colons must be added to separate multiple commands on a single line.

Run the commands by issuing the command:

$ nohup sh batchfile &

If execute permission is applied to batchfile using:

$ chmod u+rx batchfile

you can also execute batchfile using the simplified command:

$ nohup batchfile &

As in the previous example, output is appended to nohup.out unless redirected from within the file.

To run example b) above but redirect the standard output to a different file, enter:

$ nohup batchfile > output &

Output from the job is sent to a file called output not to nohup.out.

For more information about nohup type:man nohup

Author: Paul Wellings