duanne9313 2017-09-26 07:21
浏览 38

PHP ini_set max_execution_time nog是否正常工作?

To monitor the max_execution_time of a particular script, I use

ini_set('max_execution_time', 600); //600 seconds = 10 minutes

at the top of my script. However, when I build a logging of the same file it returns me the following:

25-09-2017 23:08:01|STARTED
25-09-2017 23:09:01|ALREADY RUNNING
25-09-2017 23:10:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 01:09:01|ALREADY RUNNING
26-09-2017 01:10:01|ALREADY RUNNING
26-09-2017 01:11:01|STARTED
26-09-2017 01:12:01|ALREADY RUNNING
26-09-2017 01:13:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 03:10:01|ALREADY RUNNING
26-09-2017 03:11:01|ALREADY RUNNING
26-09-2017 03:12:01|STARTED
26-09-2017 03:13:01|ALREADY RUNNING
26-09-2017 03:14:02|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 05:09:01|ALREADY RUNNING
26-09-2017 05:10:02|ALREADY RUNNING
26-09-2017 05:11:01|STARTED
26-09-2017 05:12:01|ALREADY RUNNING
26-09-2017 05:13:02|ALREADY RUNNING
26-09-2017 05:14:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 07:14:01|ALREADY RUNNING
26-09-2017 07:15:01|ALREADY RUNNING
26-09-2017 07:16:01|STARTED

The ...................|ALREADY RUNNING represents multiple messages repeating every minute in between.

What am I doing wrong, since the interval is not 10 minutes by far?

EDIT:

The while loop I have:

while (true) {
    //DO PROCESSING WHEN FILES ARE PRESENT
    Sleep(1);
    }
  • 写回答

1条回答 默认 最新

  • dtcd27183 2017-09-26 09:22
    关注

    Just check execution time manually.

    $max_exec_time = 600;
    
    $start_time = time();
    while (true) {
      do_something();
      sleep(1);
      if (time() - $start_time > $max_exec_time) {
        exit;
      }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改