从命令行杀死所有进程
我想从命令行杀死所有 Firefox 进程。
例如:
MacPro:huangr$ ps -x | grep 'firefox'
4147 ttys000 0:00.00 (firefox-bin)
4177 ttys000 0:00.00 (firefox-bin)
4234 ttys000 0:00.00 (firefox-bin)
4273 ttys000 0:00.00 (firefox-bin)
4282 ttys000 0:00.00 (firefox-bin)
4285 ttys000 0:00.00 (firefox-bin)
4298 ttys000 0:00.00 (firefox-bin)
4301 ttys000 0:00.00 (firefox-bin)
4304 ttys000 0:00.00 (firefox-bin)
4311 ttys000 0:00.00 (firefox-bin)
4317 ttys000 0:00.00 (firefox-bin)
4320 ttys000 0:00.00 (firefox-bin)
4338 ttys000 0:00.00 (firefox-bin)
4342 ttys000 0:00.00 (firefox-bin)
4377 ttys000 0:03.85 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4394 ttys000 0:05.54 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4471 ttys000 0:06.08 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4581 ttys002 0:04.92 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4607 ttys002 0:04.33 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4626 ttys002 0:05.04 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
我想一击杀死所有他们,有什么简单的方法吗? 谢谢。
I would like to killing all the firefox processes from command line.
For example:
MacPro:huangr$ ps -x | grep 'firefox'
4147 ttys000 0:00.00 (firefox-bin)
4177 ttys000 0:00.00 (firefox-bin)
4234 ttys000 0:00.00 (firefox-bin)
4273 ttys000 0:00.00 (firefox-bin)
4282 ttys000 0:00.00 (firefox-bin)
4285 ttys000 0:00.00 (firefox-bin)
4298 ttys000 0:00.00 (firefox-bin)
4301 ttys000 0:00.00 (firefox-bin)
4304 ttys000 0:00.00 (firefox-bin)
4311 ttys000 0:00.00 (firefox-bin)
4317 ttys000 0:00.00 (firefox-bin)
4320 ttys000 0:00.00 (firefox-bin)
4338 ttys000 0:00.00 (firefox-bin)
4342 ttys000 0:00.00 (firefox-bin)
4377 ttys000 0:03.85 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4394 ttys000 0:05.54 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4471 ttys000 0:06.08 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4581 ttys002 0:04.92 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4607 ttys002 0:04.33 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
4626 ttys002 0:05.04 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
I would like to kill all of them in one shot, any easy way to do that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
应该做
Should do it
这非常有效。
或者
This works perfectly.
or
旁注 -
Kill -9 是过度杀伤(没有双关语),因为它阻止被杀死的进程运行清理(例如,atexit() 调用,如 exit 和 _exit 之间的区别)。这可能是也可能不是 Firefox 的问题,但一般来说,只有在普通的“kill”失败后才考虑尝试“kill -9”。
Side note -
kill -9 is overkill (no pun intended) because it prevents the killed process from running cleanup (e.g., atexit() calls, like the difference between exit and _exit). It may or may not be a problem with firefox, but in general consider trying "kill -9" only after plain "kill" fails.
killall firefox-bin
或
killall -9 firefox-bin
如果需要,
killall firefox-bin
or
killall -9 firefox-bin
if necessary
这应该可以做到 -
或者在一般说明中,将此函数添加到您的启动脚本中 -
测试:
This should do it -
Or on a generic note, add this function to your startup script -
Test: