如何一次性杀死一个进程的多个实例?
我有一个进程的多个实例(即使用通用命令行)。我真想一口气把他们全部杀掉。如何实现?
I have several instances of a process (i.e. with a common command line). I would like to kill all of them at one go. How to achieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
选项:
Killall 非常强大,但我发现乱用很危险。选项2使用起来很尴尬,但我经常发现自己处于没有killall的环境中;另外,在第一次通过时省略 xargs 位可以让我在挥动刀片之前回顾已谴责的进程。最终,我通常更喜欢 htop,因为它可以让我在点击大“k”之前进行选择。
Options:
Killall is super powerful, but I find it hazardous to use indiscriminately. Option 2 is awkward to use, but I often find myself in environments that don't have killall; also, leaving out the xargs bit on the first pass lets me review the condemned processes before I swing the blade. Ultimately, I usually favour htop, since it lets me pick and choose before hitting the big "k".
您可能正在寻找
killall
命令。例如:将终止您计算机上正在运行的所有 perl 进程。有关更多详细信息,请参阅 http://linux.die.net/man/1/killall 。
You are probably looking for the
killall
command. For example:Would kill off all perl processes that are running on your machine. See http://linux.die.net/man/1/killall for more details.
killall
将为您做到这一点。使用man Killall
作为选项,但我通常这样做:非常小心(例如,首先使用
ps
以确保它只会杀死什么你想要)。killall
will do that for you. Useman killall
for the options but I usually do:Just be very careful (eg, use
ps
first to make sure it will only kill what you want).注意:killall 就是答案...如果您使用的是 Linux。 SysV 也有一个killall 命令,但它做了一件非常非常不同的事情:它是系统停止之前关闭进程的一部分。所以,是的,killall 是最简单的,但如果您经常在 Linux 和 SysV 系统之间穿梭,我可能会建议您编写一个快速脚本来完成您想要的操作。
NOTE: killall is the answer... IF you're on Linux. SysV also has a killall command, but it does a very, very different thing: it's part of the shutting-down-processes-prior-to-system-halt. So, yes, killall's the easiest, but if you often shuttle between Linux and SysV systems, I might recommend writing up a quick script to do what you want, instead.