Have you ever gone to exit out of a Linux terminal, only to be warned there are stopped jobs? What are these mysterious things and how do you finally stop them? Let’s figure out this puzzle.
The first thing you need to understand is what stopped jobs are. Basically, they are jobs that have been temporarily placed in the background. Say, for instance, you run the top command. Instead of actually closing it with Ctrl+C, you’d rather keep it running in the background, so you can recall it later. For that, you use the Ctrl+Z keyboard combination. When you do that, you place the command in the background.
SEE: 5 Linux server distributions you should be using (TechRepublic Premium)
This is a very handy tool when you want to switch back and forth between two commands and you only have one terminal window available. Once you send a command into the background, you’ll get your terminal prompt back so you can run other commands. But when you want to return to the command you placed in the background, you issue the fg command. if you only have one command running in the background, it’ll bring that command back to the foreground.
If you have more than one command in the background, the fg command will recall the last command sent into the shadows. You can, however, tell fg which command to bring to the foreground. To do that, you must first find out the number associated with each job using the jobs command. This will list out each stopped job. Find the number associated with the job you want to bring to the foreground and then issue fg X (Where X is the number of the job you want to bring to the foreground).
SEE: Rust: What developers need to know about this programming language (free PDF) (TechRepublic)
You can place as many jobs as you need in the background and recall them anytime you want. The one thing to know, however, is if you do exit the terminal with the stopped jobs, those jobs will exit. So if you want to keep working with those jobs, leave that terminal open.
And that’s all there is to dealing with stopped jobs on Linux.