Skip navigation

pkill & pgrep 是两个很方便的命令。省去了要先ps auwx | grep xxxx然后再根据pid kill的麻烦。例如,杀掉所有叫做wiki-import.pl的脚本

pkill -f wiki-import.pl

默认情况下,pkill & pgrep只会匹配启动程序的文件名。加上 -f 参数可以让pkill & pgrep 匹配整个命令行。比如,上面的例子就是为了匹配到“perl wiki-import.pl”.

pkill和kill一样可以向进程发送多种信号。例如:

pkill -STOP wiki-import.pl #暂停进程
pkill -CONT wiki-import.pl #唤醒进程

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>