php – 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'

我想杀死包含上述字符串的所有进程.

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

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'

..with PHP,并杀死-9所有匹配的进程?

如您所见,该过程正在使用screen命令运行.
sh -c sudo screen /usr/bin/python
sudo screen /usr/bin/python
screen /usr/bin/python

因此,您无法使用您使用的命令终止进程.

要终止进程,首先搜索进程的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 : list the process
  2. grep : grep for the requred process name
  3. awk : to get only the PID’s of the process from the grep ouput
  4. xargs sudo kill -9 : xargs will pass one by one PID number to kill command

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...