How to send long running jobs to background ?

In this post we will learn how to send a long running jobs to background and foreground.

When you run any command on the Linux terminal it executes immediately but what if it takes long time ? X What you do when it takes few minutes you have to wait till it gets completed.

So often what you do is start another terminal and work on it. If its a server then you may need that same terminal.

So lets see how to free your terminal and send the job to background.

You can send the jobs background if its already started, for that we use bf, fg and jobs commands.

If you want to send job to background when its starting then you use the ‘&’ in the end of command.

To start job in the background put & in the end as shown below.

$ node export.js "" video1.webm 0 true &

Above job gets a video from the url and then converts into mp4, ths process takes lot of time, so better we start this process in the background itself.

To send already started job to background

Lets say you already started the job and then you want to send it to background. To do ths you need to press Ctl + Z this will stop the process, then you use bg command to send it background.

$ node export.js "" video1.webm 0 true
---->  Ctl + Z
[1]+  Stopped
$ bg

To bring it again in foreground use fg command. When you send multliple jobs to background you will get its ids like [2]+ or [3]+ to get specfc job to foreground you can use its jobs number wth fg as shown below

$ fg 2

List all background jobs

To get the list of all background jobs you can use jobs command as shown below

$ jobs
[1]+  Running       node export.js

Here only one job is running in the background.

Kill running job

To kill the running job you can simply use the Ctl + C. First get the command in the foreground and then use Ctrl + C to kill the job.


  1. Ctl + Z to stop jobs
  2. Use bg command to send job to background
  3. Use Jobs to see background running jobs
  4. fg with number bring specific job to foreground
  5. Use Ctrl + C to kill the job.