jobs Command in Linux: List and Manage Background Jobs

The jobs command is a Bash built-in that lists all background and suspended processes associated with the current shell session. It shows the job ID, state, and the command that started each job.
This article explains how to use the jobs command, what each option does, and how job specifications work for targeting individual jobs.
Syntax
The general syntax for the jobs command is:
jobs [OPTIONS] [JOB_SPEC...]
jobs -x COMMAND [ARGS...]When called without arguments, jobs lists all active jobs in the current shell.
Listing Jobs
To see all background and suspended jobs, run jobs without any arguments:
jobsIf you suspend Vim with Ctrl+Z and then start ping in the background, the output will look similar to this:
[1]+ Stopped vim notes.txt
[2]- Running ping google.com > /dev/null &Each line shows:
- The job number in brackets (
[1],[2]) - A
+or-sign indicating the current and previous job (more on this below) - The job state (
Running,Stopped,Done) - The command that started the job
The stopped Vim job is marked with + even though ping started later. Bash keeps a stopped job as the current job, so running fg without arguments brings Vim back to the foreground.
To include the process ID (PID) in the output, use the -l option:
jobs -l[1]+ 14205 Stopped vim notes.txt
[2]- 14230 Running ping google.com > /dev/null &The PID is useful when you need to send a signal to a process with the kill
command.
Job States
Jobs reported by the jobs command can be in one of these states:
Running- The process is actively executing in the background.Stopped- The process has been suspended, typically by pressingCtrl+Z. A job stopped by another signal shows asStopped (signal).Done- The process finished with exit status 0. This state appears once and is then cleared from the list.Exit N- The process finished with a non-zero exit status, for exampleExit 1.Terminated- The process was killed bySIGTERM, the default signal sent bykill.Killed- The process was killed bySIGKILL, for example withkill -9.
When a background job finishes, Bash normally reports its final status before displaying the next prompt.
Job Specifications
Job specifications (job specs) let you target a specific job when using commands like fg, bg, kill
, or disown. They always start with a percent sign (%):
%1,%2, … - Refer to a job by its number.%%or%+- The current job, marked with+. This is usually the job you most recently started in the background or suspended. A stopped job stays current even after you start a newer background job.%-- The previous job (marked with-).%string- The job whose command starts withstring. For example,%pingmatches a job started withping google.com.%?string- The job whose command containsstringanywhere. For example,%?googlealso matchesping google.com.
If a prefix or substring matches more than one job, Bash prints an ambiguous job spec error. Use the job number instead.
Here is a practical example. Start two background jobs:
sleep 300 &
ping -c 100 google.com > /dev/null &Now list them:
jobs[1]- Running sleep 300 &
[2]+ Running ping -c 100 google.com > /dev/null &You can bring the sleep job to the foreground by its number:
fg %1Or by the command prefix:
fg %sleepBoth are equivalent and bring job [1] to the foreground.
Options
The jobs command accepts the following options:
-l- List jobs with their process IDs in addition to the normal output-p- Print only the PID of each job’s process group leader (useful for scripting)-r- List only running jobs-s- List only stopped (suspended) jobs-n- Show only jobs whose status has changed since the last notification-x COMMAND- RunCOMMANDafter replacing each job spec in its arguments with the job’s process group ID
To show only running jobs:
jobs -rTo get just the PIDs of all jobs:
jobs -p14205
14230Using jobs in Scripts
Job control is off in a non-interactive script, but Bash still tracks the background processes the script starts. The jobs command lists them, and jobs -p prints their PIDs. What does not work is moving a job between the foreground and the background. Calling fg or bg in a script fails with a fg: no job control error. To turn job control on in a script, add set -m near the top.
To track a specific task, save its process ID from $! right after you start it:
# Start a background task
long_task &
task_pid=$!
# Poll until it finishes
while kill -0 "$task_pid" 2>/dev/null; do
echo "Task is still running..."
sleep 5
done
echo "Task complete."To wait for several background tasks, store their PIDs and pass them to wait:
task_a &
pid_a=$!
task_b &
pid_b=$!
task_c &
pid_c=$!
wait "$pid_a" "$pid_b" "$pid_c"
echo "All tasks complete."To check each task’s exit status, call wait separately for each saved PID. Save each PID with $! immediately after starting the task, because collecting PIDs later with jobs -p can miss tasks that have already finished and been removed from the job table. See our Bash wait
guide for more examples of checking exit statuses.
The wait command accepts a job spec as well:
wait %1Quick Reference
For a printable quick reference, see the Job Control cheatsheet .
| Command | Description |
|---|---|
jobs | List all background and stopped jobs |
jobs -l | List jobs with PIDs |
jobs -p | Print only PIDs |
jobs -r | List only running jobs |
jobs -s | List only stopped jobs |
fg %1 | Bring job 1 to the foreground |
bg %1 | Resume job 1 in the background |
kill %1 | Terminate job 1 |
disown %1 | Remove job 1 from the job table |
wait | Wait for all background jobs to finish |
FAQ
What is the difference between jobs and ps?jobs shows only the processes started from the current shell session. Use ps -e
to list all processes on the system, regardless of which shell started them.
Why does jobs show nothing even though processes are running?jobs only tracks processes started from the current shell. If you started a process in a different terminal or via a system service, it will not appear in jobs. Use ps aux to find it instead. Jobs removed with disown are also dropped from the list.
How do I stop a background job?
Use kill %N where N is the job number. For example, kill %1 sends SIGTERM to job 1. If the job does not stop, use kill -9 %1 to force-terminate it.
What do the + and - signs mean in jobs output?
The + marks the current job, the one that fg and bg will act on by default. The - marks the previous job. When the current job finishes, the previous job becomes the new current job. A stopped job stays current even when you start a newer job in the background.
How do I keep a background job running after closing the terminal?
Use nohup
before the command, or disown after backgrounding it. For long-running interactive sessions, consider Screen
or Tmux
.
Conclusion
The jobs command lists all background and suspended processes in the current shell session. Use it together with fg, bg, and kill to control jobs interactively. For a broader guide on running and managing background processes, see How to Run Linux Commands in the Background
.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page