首页·终端命令

jobs

进程与系统

用法

jobs [-l]

这是 shell 内建命令,只给当前 shell 的后台任务编号,别的终端里的任务不会出现,引用时写 `%1` 而不是 PID。

常用选项

选项含义
-lInclude the PID of each job.
-pPrint only PIDs, handy for piping into kill.
-rRunning jobs only.
-sStopped jobs only.

示例

jobs -l

List the background jobs of this shell with their PIDs.

kill %1

Stop job number 1 as shown by jobs.

看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. jobs 是做什么的?

这是 shell 内建命令,只给当前 shell 的后台任务编号,别的终端里的任务不会出现,引用时写 `%1` 而不是 PID。

Q. 怎么写?

jobs [-l] —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 4 个,完整列表在 man jobs。这条命令属于进程与系统。

相关命令

man 手册: man jobs