【问题标题】:order of executing shell_exec in phpphp中shell_exec的执行顺序
【发布时间】:2016-11-06 08:23:06
【问题描述】:

我想执行 2 个脚本:s1s2s2 必须在 s1 之后执行。 s1的执行时间是2800秒,我需要在s2之后执行s1。我应该将sleep(3000) 放在我的 php 中它们之间,还是第二个会在第一个之后执行自动

我试过了:

exec('python s1 '); //time of execution is 2800s

sleep(3000); // i want to be sure that the first one is finished

shell_exec('php /home/Parik/s2.php');

【问题讨论】:

    标签: php python


    【解决方案1】:

    来自exec 手册页:

    如果使用此函数启动程序,为了使其继续在后台运行,必须将程序的输出重定向到文件或另一个输出流。否则会导致 PHP 挂起,直到程序执行结束。

    简而言之,PHP 将等待您的 python s1 命令完成后再继续。

    请注意,在不更改 ini 文件中默认的最大执行时间的情况下,3000 秒的执行时间肯定会超时。见How to increase maximum execution time in php

    【讨论】:

      猜你喜欢
      • 2018-12-08
      • 2012-04-10
      • 2013-01-01
      • 2018-05-26
      • 2012-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多