PHP set timeout for script with system call, set_time_limit not working

前端 未结 4 1389
遇见更好的自我
遇见更好的自我 2020-12-10 08:45

I have a command-line PHP script that runs a wget request using each member of an array with foreach. This wget request can sometimes take a long time so I want to be able t

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 09:12

    You can direct the output of the wget program to a file, which then returns immediately.
    Also see:

    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(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

    Source: set_time_limit() @ php.net

提交回复
热议问题