LinuxCommandLibrary

jobs

List background jobs

TLDR

Show status of all jobs

$ jobs
copy

Show status of a particular job
$ jobs %[job_id]
copy

Show status and process IDs of all jobs
$ jobs -l
copy

Show process IDs of all jobs
$ jobs -p
copy

SYNOPSIS

jobs [-l|-n|-p|-r|-s] [jobspec …]
jobs -x command [args]

PARAMETERS

-l
    List process IDs with job info

-n
    Show only jobs with changed status since last notification

-p
    Print only process group leader PIDs

-r
    Restrict to running jobs

-s
    Restrict to stopped jobs

-x
    Replace jobspec with PID in command and execute

DESCRIPTION

The jobs command, a shell builtin in Bash and similar shells, displays the status of active jobs managed by the current shell. Jobs are background processes started with & or suspended via Ctrl-Z. It enables efficient job control in interactive sessions, showing job numbers, status (Running, Stopped, Done), and commands.

Default output marks the current job with +, previous with -, e.g., [1]+ Stopped vim file.txt. This aids multitasking without new terminals. Jobs exist only in the shell that launched them and require job control (enabled by default in interactive shells).

Use with fg, bg to manage. Output updates on status changes, but options filter or add details like PIDs. Essential for developers, sysadmins handling concurrent tasks.

CAVEATS

Only works in interactive shells with job control; jobs are shell-specific and lost on shell exit unless disowned.

JOB SPECIFIERS

Use %n (job number), %string (command prefix), %+ (current), %- (previous), or %?string (match).

OUTPUT FORMAT

[jobspec] status command (e.g., [1]+ Running sleep 100 &)

HISTORY

Originated in BSD C-shell (csh) with job control (~1979); adopted in POSIX.1-2008; Bash implementation since 1989, evolving with shell standards.

SEE ALSO

fg(1), bg(1), disown(1), wait(1)

Copied to clipboard