The jobs
command is a built-in Linux command that is used to display the status of jobs that are running in the background or suspended. It is used to check the status of jobs that are started with &
or ctrl+z
commands.
Overview
The jobs
command displays a list of all jobs that are running in the background or suspended. It provides information such as the job number, status, and command that is associated with each job. The job number is used to identify a specific job when using other commands such as fg
or kill
.
The jobs
command can be used in various ways, including:
- Display a list of all jobs that are running in the background or suspended:
$ jobs
- Display the status of a specific job by specifying the job number:
$ jobs %1
- Display the status of all jobs in the current shell session:
$ jobs -l
Options
The jobs
command comes with the following options:
Option | Description |
---|---|
-l |
Displays the process ID (PID) of each job in addition to the job number and status. |
-n |
Displays the status of jobs that have changed since the last notification. |
-p |
Displays only the process ID (PID) of each job. |
-r |
Displays only running jobs. |
-s |
Displays only suspended jobs. |
Troubleshooting tips
- If the
jobs
command does not display any output, it means that there are no jobs currently running in the background or suspended. - If you are unable to identify a specific job using the job number, it may have already completed or been terminated.
- If the
jobs
command is not working as expected, try using theps
command to display a list of all running processes and their status.
Notes
- The
jobs
command only displays the status of jobs that are started in the current shell session. If you start a job in a different shell session, it will not be displayed in the output of thejobs
command. - The job number is assigned based on the order in which jobs are started. The first job that is started will have a job number of
1
, the second job will have a job number of2
, and so on.