加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Pkill -f不适用于进程终止

发布时间:2020-12-13 18:13:57 所属栏目:PHP教程 来源:网络整理
导读:我正在运行此进程: 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 /
我正在运行此进程:
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读