Running multiple jobs on a command line interface isn’t intuitive, because there’s only one command prompt.
Tools like tmux and screen are helpful because they give multiple terminals, multiple command prompts.
Before these tools, UNIX systems had a way to have multiple jobs
running on a single command prompt, through the tools:
||lists currently running background jobs|
||brings the last running background job to the foreground|
||start stopped job to run in the background|
||stop the current foreground job|
||start the current job in the background|
Let’s try these commands out.
I will use the
sleep command to practice. First let’s create job:
At this point, the prompt will freeze, because the sleep command is executing.
Stopping Running Job
To stop the job, enter:
Resurrecting Stopped Job
To bring this job back to the foreground, run:
And the job will resume as it was previously.
Resurrecting Stopped Job to Background
To start a stopped job in the background, run:
Viewing Background Jobs
Now, the job will run in the background. To see the job running, run
Starting a Background Job
If you noticed, running
bg on a stopped job, basically executed the
command with an
& appended. Appending
& to a command will
automatically start the command in the background, for example, if we
added another job to the current background job:
The system uses the value 50990 to track of running processes.
fg will bring the last command, in this instance,
To control a specified job, use its job number:
Have you noticed some jobs have a
- next to them? These are
+the default job that command to apply against, like
-the job that using
-option to apply to, like:
UNIX is a multiprocessing system, even with a single interface such as
a command line, one can manage multiple concurrent jobs with ease just
UNIX surprises me how much is possible on such a simple interface!