Using job control in Bash
Not only will job control give you a better understanding of foreground and background processes, but it will also make you more efficient when working on a terminal. Being able to put a process in the background frees up your terminal to do other tasks.
Getting ready
Nothing particular is required for this recipe, except for the Bash shell. Bash is most often the default shell, so it's likely that you already have it installed.
How to do it…
In this recipe, we will start and stop several processes, send them to the background, and bring them back to the foreground. This will give us an understanding of background and foreground processes. Let's get started:
- Previously, we have seen how to start a process in the background with an ampersand (
&
). We will repeat that here, but we will also list the current jobs running and bring one of them to the foreground. The first background process we'll start here issleep...