Pkill -f不适用于进程查杀

我有这个过程运行:

342 pts/2 T 0:00 sh -c sudo screen /usr/bin/python /usr/bin/btdownloadcurses "http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent" --display_interval 20 --saveas "/srv/" 343 pts/2 T 0:00 sudo screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/ 344 pts/2 T 0:00 screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/ 

我试图运行:

 pkill -f http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent 

但是这个过程还在继续。
如何强制杀死包含以下内容的进程:“ http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent ”?


问题编辑如下:

 ps ax | grep 'Momomoko.E01.140011.HDTV.H264.720p.mp4' 

我想杀死包含上面string的所有进程。

我试着运行上面的代码,它返回三个结果:

  342 pts/2 T 0:00 sh -c sudo screen /usr/bin/python /usr/bin/btdownloadcurses "http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent" --display_interval 20 --saveas "/srv/Momomoko.E01.140011.HDTV.H264.720p.mp4" 343 pts/2 T 0:00 sudo screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/Momomoko.E01.140011.HDTV.H264.720p.mp4 344 pts/2 T 0:00 screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/Momomoko.E01.140011.HDTV.H264.720p.mp4 

我如何运行这一行:

 ps ax | grep 'Momomoko.E01.140011.HDTV.H264.720p.mp4' 

..用PHP,并kill -9所有的匹配过程?

正如您所看到的,该进程正在使用屏幕命令运行。

 sh -c sudo screen /usr/bin/python sudo screen /usr/bin/python screen /usr/bin/python 

由于这个,你不能用你所使用的命令kill进程。

要终止进程,首先搜索进程的PID进程ID,然后使用带有PID的kill命令。 喜欢

 $ **kill -9 342** 

同样从你的进程列表来看,你可以看到你已经用不同的权限多次启动了相同的进程。 所以我建议你杀掉除了需要的东西之外的所有东西。

编辑:这个单一的命令就足够了;

 $ ps ax | grep 'Momomoko.E01.140011.HDTV.H264.720p.mp4' | awk -F ' ' '{print $1}' | xargs sudo kill -9 

这是它的作用:

  1. ps ax:列出过程
  2. grep:grep所需的进程名称
  3. awk:只从grep输出中获得进程的PID
  4. xargs sudo kill -9:xargs会逐一传递PID号码来杀死命令

尝试使用kill命令

 kill -9 <pid> 

这将是肯定的,因为我已经尝试过自己,非常方便所有的时间。

在脚本文件中使用以下命令,然后使用kill命令运行循环,

 ps|grep torrent|cut -f1 -d' ' 

像下面这样for循环,作为我的系统的确切的工作副本;

 for p in `ps|grep torrent|cut -f1 -d' '`; do kill -9 $p done 

我希望这会最终帮助你。