builtin

jobs

List current shell jobs. -p prints process group leader IDs; -r limits to running jobs and -s to stopped jobs. This is not a system-wide process inventory.

Formal Syntax & Structure

bash syntaxbash
jobs [-lnprs] [jobspec]

Parameters & Attributes

NameTypeDescription
jobspecjob identifierCurrent shell job to inspect.

Return Value

exit status

List current shell jobs. -p prints process group leader IDs; -r limits to running jobs and -s to stopped jobs. This is not a system-wide process inventory.

Working Example

Example Snippetbash
sleep 0.3 &pid=$!jobs -p > jobs.txtif grep -Fxq "$pid" jobs.txt; then    printf 'job listed\n'else    exit 1fiwait "$pid"
Bash Reference