如何限制php脚本的执行时间


How to limit execution time on a php script

我通过Linux运行php脚本(不是通过我的浏览器)(php script.php)。现在,我想将执行时间限制为10秒,这意味着10秒后进程将自行关闭。我该怎么做呢?已经尝试了set_time_limit。已经试过睡觉了(10);退出();

更改php.ini配置文件中的最大执行时间(以秒为单位)。

max_execution_time = 7200

查找php.ini

使用set_time_limit函数如何?

void set_time_limit ( int $seconds )