<?php
$real_execution_time_limit = 60; //时间限制
if (pcntl_fork())
{
// some long time code which should be
// terminated after $real_execution_time_limit seconds passed if it's not
// finished by that time
}
else
{
sleep($real_execution_time_limit);
posix_kill(posix_getppid(), SIGKILL);
}
如果是web中,以fpm 方式执行,那么可以修改:/etc/php5/fpm/pool.d/www.conf 中的 request_terminate_timeout。 如果想看哪些脚本超时了,可以配置:request_slowlog_timeout 和 slowlog
另外需要配置apache 的站点中配置 FastCgiExternalServer -idle-timeout 300