$ ps aux | grep ruby
user 1565 3.7 0.1 4307464 17696 s000 S+ 7:31AM 0:00.61 /Users/user/.rbenv/versions/2.3.1/bin/ruby bin/rails c
user 1579 0.0 0.0 4268020 788 s001 S+ 7:31AM 0:00.00 grep ruby
user 1489 0.0 0.0 0 0 ?? Z 7:29AM 0:00.00 (ruby)
如何快速终止所有这些进程?
我尝试过的:
kill -9 `ps aux | grep ruby`
我的环境:
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
$ uname -a
Darwin MacBook-Pro.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
$
答案1
正如 Haxiel 评论的那样,我的建议是使用杀戮:
pkill -9 ruby
答案2
kill $(ps aux | grep ruby | grep -v grep | awk '{print $2}' | xargs)
for p in $(ps aux | grep ruby | grep -v grep | awk '{print $2}'); do kill $p; done
kill9
有需要的话可以替换kill
。
答案3
我尝试使用以下命令
ps -eaf | grep -i ruby| grep -iv 'grep'| awk '{print "kill -9" " " $2}'| sh