Managing jobs in the background

A program is started in the background by appending an ampersand (&) to the end of a command. On launching the program in the background, it displays a job ID (unique for the running session) and the PID of the background process, as shown in the following screenshot:

Use the jobs command to display the background jobs associated with the shell. The jobs command displays the job ID, state, and command name. If there is more the one background job, the default selection will have + in front of it, as shown in the following screenshot:

The fg command is used to bring a background job to the foreground using its job ID. The job ID and the % of the program is followed by the job number displayed in square brackets, as shown in the following screenshot:

Send a foreground program to the background by first suspending it using Ctrl + Z on the Terminal, as shown in the following screenshot:

The jobs command, when used with the -l option, will also list the program ID. To get some more information, we can use the ps command with the j option, as shown in the following screenshot:

The bg command followed by % and the job ID is used to start a stopped program in the background, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.209.8