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

杀死后台php脚本(共享主机)

发布时间:2020-12-13 13:28:46 所属栏目:PHP教程 来源:网络整理
导读:我创建了一个使用ignore_user_abort()函数在后台运行的脚本.但是,我愚蠢到不插入任何类型的代码来使脚本停止,现在它每30秒发送一次电子邮件…… 有没有办法停止脚本?我在共享主机中,所以我无法访问命令提示符,我不知道PID. Is there any way to stop the sc
我创建了一个使用ignore_user_abort()函数在后台运行的脚本.但是,我愚蠢到不插入任何类型的代码来使脚本停止,现在它每30秒发送一次电子邮件……

有没有办法停止脚本?我在共享主机中,所以我无法访问命令提示符,我不知道PID.

Is there any way to stop the script? I am in a shared hosting,so I don’t have access to the command prompt,and I don’t know the PID.

那就不要.

但是你确定你没有任何shell访问权限吗?即使通过PHP?如果你这样做,你可以尝试….

<?php

print `ps -ef | grep php`;

……如果你能从中识别出那个过程……

<?php

$pid=12345; // for example.
print `kill -9 $pid`;

即使您没有运行shell命令的权限,您也可以在/ proc(在Linux系统上)找到pid并使用POSIX扩展来终止它….

<?php

$ps=glob('/proc/[0-9]*');
foreach ($ps as $p) {
    if (is_dir($p) && is_writeable($p)) {
        print "proc= " . basename($p);
        $cmd=file_get_contents($p . '/cmdline');
        print " / " . file_get_contents($p . '/cmdline');
        if (preg_match('/(php).*(myscript.php)/',$cmd)) {
            posix_kill(basename($p),SIGKILL);
            print " xxxxx....";
            break;
        }
        print "n";
    }  
}

(编辑:李大同)

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

    推荐文章
      热点阅读