如何杀死与'grep'结合'kill'的进程 [英] How to kill a process with 'kill' combined with 'grep'
问题描述
我想用一个简单的命令杀死一个进程/脚本。目前我做了以下工作:
ps -ef | grep myscriptname
kill 123456
但是有没有办法将2个命令组合在一起我不需要查看和手动编写pid,像这样 kill grep myscriptname
?
你想要 pkill
:
pkill myscriptname
在某些系统上有一个类似的工具叫做 killall
,但要小心,因为在Solaris上它确实会杀死所有东西!
请注意,还有 pgrep
您可以使用它来替换 ps | grep
pipeline:
pgrep myscriptname
它会为您打印PID,而不是其他内容。
I'd like to kill a process/script with a simple command using. At the moment I do the following
ps -ef | grep myscriptname
kill 123456
But is there a way to maybe combine the 2 command together so I don't need to look and manually write the pid, something like this kill grep myscriptname
?
You want pkill
:
pkill myscriptname
On some systems there is a similar tool called killall
, but be careful because on Solaris it really does kill everything!
Note that there is also pgrep
which you can use to replace your ps | grep
pipeline:
pgrep myscriptname
It prints the PID for you, and nothing else.
这篇关于如何杀死与'grep'结合'kill'的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!