Linux / Unix: jobs Command Examples

Linux / Unix: jobs Command Examples

The jobs command is a Unix and Linux utility that displays a list of jobs that are running or stopped in the background or suspended in the foreground of the current shell.

Here is the basic syntax for using the jobs command:

refer‮ot ‬:lautturi.com
jobs

The jobs command does not take any arguments.

To use the jobs command, you first need to start a job in the background or suspend a job in the foreground.

To start a job in the background, you can use the & operator at the end of the command.

For example, to start the sleep command in the background, you can use the following command:

sleep 100 &

This will start the sleep command in the background and return control to the shell prompt.

To suspend a job in the foreground, you can use the CTRL+Z key combination.

For example, to suspend the sleep command in the foreground, you can use the following command:

sleep 100

Then, while the sleep command is running, press CTRL+Z to suspend it.

Once you have a job running or suspended in the background or foreground, you can use the jobs command to display a list of jobs.

For example:

jobs

This will display a list of jobs that are running or stopped in the background or suspended in the foreground of the current shell.

Each job is assigned a job number, and the status of the job is indicated by a symbol. For example, a + symbol indicates that the job is the current foreground job, and a - symbol indicates that the job is the previous foreground job.

You can use the fg command to bring a background or suspended job to the foreground, and the bg command to resume a stopped job in the background.

For example:

fg %1  # bring job 1 to the foreground
bg %2  # resume job 2 in the background
Created Time:2017-10-29 22:09:00  Author:lautturi