We will now look at background processes and discuss how to start, view, and stop them.
There are times when processes may be running in the background. To view the processes that are running in the background, use the following command:
jobs
By default, this is blank as you might not have jobs running in the background.
You might want to start a process directly in background. To do so, suffix the ampersand (&
) symbol after the process name when starting it. You might have observed this in the earlier sections of this chapter. Let's start the sleep
process in the background now. The command to do so is as follows:
sleep 1000 &
Now, let's check whether the process was started successfully and is running in the background using the jobs
command:
Here, we first checked for any processes running in the background using the jobs
command. Initially, it showed nothing, which means no jobs are running in the background. Next, we start the sleep
process...