killall
进程与系统
用法
killall [-SIGNAL] <name>按名字而不是 PID 一次结束多个进程;名字必须和可执行文件完全一致,所以 `killall chrome` 抓不到叫 "Google Chrome" 的进程。
常用选项
| 选项 | 含义 |
|---|---|
| -9 | Force, with no chance for the process to clean up. |
| -i | Ask for confirmation before each kill (Linux). |
| -u <user> | Only the processes of that user with this name. |
| -e | Require an exact match for names longer than 15 characters (Linux). |
| -w | Wait until the processes are really gone (Linux). |
| -m <pattern> | Treat the argument as a regular expression (macOS/BSD). |
示例
killall nodeStop every process whose executable is named node.
killall -9 DockForce-restart the macOS Dock, which relaunches itself.
看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. killall 是做什么的?
按名字而不是 PID 一次结束多个进程;名字必须和可执行文件完全一致,所以 `killall chrome` 抓不到叫 "Google Chrome" 的进程。
Q. 怎么写?
killall [-SIGNAL] <name> —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 6 个,完整列表在 man killall。这条命令属于进程与系统。
相关命令
man 手册: man killall