如何用exec停止PHP文件的执行

时间:2017-11-01 05:15:45

标签: php python-2.7

我编写了几个脚本来实现 Marquee效果

我的想法是php脚本负责执行,py脚本处理控制流。

我的file.php:

<?php
exec(" sudo python /var/www/html/3ledblink.py");
?>

我的file.py我用来循环(While)

          while True:

        # Red for 7 seconds
                trafficState(1,0,0)
                time.sleep(7)

       # Green for 5 seconds
                trafficState(0,1,0)
                time.sleep(5)

        # Yellow for 2 seconds
                trafficState(0,0,1)
                time.sleep(2)

现在我无法阻止它。 请帮我。 谢谢。

2 个答案:

答案 0 :(得分:1)

您无法使用PHP停止exec处理运行时。

如果要停止无限执行命令进程,则应重新启动Apache服务器。因为一旦使用PHP开火,你就无法停止执行命令。

答案 1 :(得分:0)

如果您在终端中运行php文件,只需按ctrl+c即可终止