How do I run a Unix process in the background?
In Unix, a background process executes independently of the
shell, leaving the terminal free for other work. To run a
process in the background, include an &
(an ampersand) at the end of the command you use to run the
job. Following are some examples:
- To run the
countprogram, which will display the process identification number of the job, enter: count & - To check the status of your job, enter: ps
- To bring a background process to the foreground, enter: fg
- If you have more than one job suspended in the background, enter:
fg %#
Replace
#with the job number, as shown in the first column of the output of thejobscommand. - You can kill a background process by entering:
kill PID
Replace
kill -KILL PIDPIDwith the process ID of the job. If that fails, enter the following: - To determine a job's PID, enter: jobs -l
- If you are using
sh,ksh,bash, orzsh, you may prevent background processes from sending error messages to the terminal. Redirect the output to/dev/nullusing the following syntax: count 2> /dev/null &
At Indiana University, to get support for personal or departmental Linux or Unix systems, see At IU, how do I get support for Linux or Unix?
Also see:
- In Unix, how should I submit CPU-intensive jobs?
- In Unix, how do I cancel a batch job?
- In Unix, why can't I kill certain background processes even with kill -9?
- In Unix, what do the output fields of the ps command mean?
- Unix job control command list
- Introduction to Unix commands
This is document afnz in domain all.
Last modified on September 23, 2008.
Last modified on September 23, 2008.
Please tell us, did you find the answer to your question?






