Set max_execution_time in PHP CLI

前端 未结 4 1865
渐次进展
渐次进展 2020-12-01 04:37

I know that PHP CLI is usually used because of none time limits and primary because it is not using Apache threads/processes.

But is there any way how to explicitly

4条回答
  •  无人及你
    2020-12-01 04:42

    set_time_limit() works in CLI scripts.

    
    

    After one second returns with the following error message:

    PHP Fatal error:  Maximum execution time of 1 second exceeded in \
    /home/stivlo/test.php on line 4
    

    Initially I tried with sleep() and the time limit doesn't get applied. As @Jon suggested, using a real computation, like an infinite loop works.

    I found this interesting comment in the sleep() PHP page:

    Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), the sleep() function, database queries, etc. is not included when determining the maximum time that the script has been running

提交回复
热议问题