jobs
List background jobs
TLDR
Show status of all jobs
Show status of a particular job
Show status and process IDs of all jobs
Show process IDs of all jobs
SYNOPSIS
jobs [-l|-p] [job_id...]
jobs -n|-r|-s
PARAMETERS
-l
Lists process ID's in addition to the normal information.
-p
Lists process ID's only, one per line.
-n
Lists jobs that have changed status since last notified.
-r
Lists only running jobs.
-s
Lists only stopped jobs.
job_id
Specifies the job(s) to be listed. If not provided, all jobs are listed. Job ID can be a process id or job number
DESCRIPTION
The jobs
command displays the status of background processes, also known as jobs, that are currently running or have stopped in the current shell environment. This is particularly useful when you've started a process with &
, which places it in the background, freeing up your terminal for other tasks. The jobs
command provides information about each job's state, such as whether it is running, stopped, or terminated. It also displays the job's ID (prefixed with %
) and the command that was executed. Using jobs
allows you to manage these background processes, bringing them to the foreground with fg
or terminating them with kill
. Without any options, jobs
lists all running and stopped jobs. Options allow filtering the output to show only running or stopped jobs or using specific job IDs.
CAVEATS
The jobs
command is shell-specific. The jobs listed are those managed by the current shell. Subshells or other shells won't be reflected.
The behavior may depend on the specific shell implementation (e.g., bash, zsh, etc.).
JOB IDS
Job IDs are distinct from process IDs. Job IDs are how the shell tracks background processes. They are typically displayed with a leading %
sign (e.g., %1
). You can use these IDs with commands like fg %1
to bring job 1 to the foreground, or kill %1
to send a signal (like terminate) to job 1.
EXIT STATUS
The jobs
command itself typically returns an exit status of 0 if successful. A non-zero exit status might indicate an error, such as an invalid option or if any specified jobs do not exist.
HISTORY
The jobs
command is a standard Unix utility, designed to provide a mechanism for managing background processes initiated from a shell. Its development closely tied to the introduction of job control in Unix systems. Job control allows users to suspend, resume, and terminate processes easily. The jobs
command allows users to inspect the status of these background processes and interacts with them, making multitasking much more manageable.