Displays the status of the job.
jobs [-lnprs] [jobspec ...]
jobs -x command [args]
-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.
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.
[user2@pc] ssh 192.168.1.4
[email protected]'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
The job control commands of bash include bg fg kill wait disown suspend.
This command can only be executed when the set option monitor is turned on; to view the job control status: enter set -o to view the monitor line; execute set -o monitor or set -m to turn it on this option.
This command is a built-in bash command. For related help information, please see the help command.
优先推荐相关内容,同时保留你的阅读轨迹和收藏入口。