jobs

Displays the status of the job.

Summary

jobs [-lnprs] [jobspec ...]
jobs -x command [args]

The main purpose

Options

-l additionally lists PIDs in job information.
-n List only jobs whose status has changed since the last notification.
-p List only PIDs.
-r Output only running jobs.
-s Outputs only stopped jobs.

return value

The return status is success unless an illegal option is given or an execution error occurs.

If executed using jobs -x command [args] form, the return value is the exit status of command.

example

[user2@pc] ssh 192.168.1.4
pc@192.168.1.4's password:
# Press ctrl+z at this time to stop the interaction.
[1]+ Stopped ssh 192.168.1.4

[user2@pc] sleep 60 &
[2] 13338

[user2@pc] jobs
[1]- Stopped ssh 192.168.1.4
[2] Running sleep 60 &

[user2@pc] jobs -l
[1]- 12927 Stopped ssh 192.168.1.4
[2] 13338 Running sleep 60 &

[user2@pc] jobs -p
12927
13338

[user2@pc] jobs -s
[1]- Stopped ssh 192.168.1.4

[user2@pc] jobs -r
[2] Running sleep 60 &

[user2@pc] kill -9 12927
[2] Done sleep 60

[user2@pc] jobs -n -l
[1]+ 12927 Killed ssh 192.168.1.4

[user2@pc] jobs -n -l

Notice