Solaris Advanced User's Guide

Running Commands in the Background

When you type a command and press the Return key, your system runs the command, waits for the command to complete a task, and then prompts you for another command. However, some commands can take a long time to finish, and you might prefer to type other commands in the meantime. If you want to run additional commands while a previous command runs, you can run a command in the background.

If you know you want to run a command in the background, type an ampersand (&) after the command as shown in the following example.

$ bigjob &
[1] 7493

The number that follows is the process id. The command bigjob will now run in the background, and you can continue to type other commands. After the job completes, you will see a message similar to the following the next time you type another command, such as date in the following example.

$ date
Tue Oct 31 15:44:59 MST 2000
[1]    Done                 bigjob

If you plan to log off before a background job completes, use the nohup (no hangup) command to enable the job to complete, as shown in the following example. If you do not use the nohup command , the background job terminates when you log off.

$ nohup bigjob &
[3] 7495