[Unix] Run A Process In Background


[How To] Execute a process in background

We often wish to run processes independently of the shell, leaving the terminal free for other tasks. To run a process in the background, include an & (an ampersand) at the end of the command you use to run the job.

This can be a simple command or a script. After the execution of the command (successful or unsuccessful) the shell returns the rerun status along with return code. We can check the status of the command at any point of time using the ps command.

To run a script, in background, enter:
  $ scriptname &
 
To check the status of your job, enter:
 $ ps

To bring the last script running in background to foreground:
$ fg

To KILL a process running in background, first find its PID using ps and then use the KILL command as follows:
$ kill PID

Waiting to hear your comments!!