Unix Job Control


Job control is used to run more than one command at a time. You can only have one command at a time running in the foreground, but you may have multiple commands running at the same time in the background. To run a command in the background, place an ampersand (&) at the end of your Unix command.

To find out what jobs/processes you currently have in the background, type jobs -l at the prompt and it will list the jobs and their statuses:

z123456@turing:~$ jobs -l
[1]  14971 Running                 ./loop &
[2]- 14972 Stopped (signal)        nano prog1.cpp
[3]+ 14978 Stopped                 ./loop2
z123456@turing:~$

The number inside the [ ] is the job number. The next number is the process identification number (PID) of the job. The next column tells us about the state of the job, and the last column is the name of the process. The + stands for the current job and the - stands for the previous job.

As you can see jobs 2 and 3 are stopped in the background and job 1, the program loop, is running in the background.