我有这个密码
$url="site.com";//~
$opts=array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept: */*i\r\n".
"User-Agent: Your application name\r\n",
"ignore_errors" => true,
"timeout" => 1800
),
"ssl"=>array(
"allow_self_signed"=>true,
"verify_peer"=>false,
"verify_peer_name"=>false,
)
);
$page = file_get_contents($url, false, stream_context_create($opts));
...
...如果$url (网页)是小规模-脚本工作良好。
但当尺寸很大,运行时间开始超过120秒时-
进程将中止并显示504错误。
--
在脚本的开头,我添加:
ini_set('max_execution_time',18000);
ini_set('default_socket_timeout',18000);
ignore_user_abort(true);
ini_set('memory_limit','512M');在ini.php中,我添加以下内容:
max_execution_time = 18000;
max_input_time = 18000;但什么都帮不上忙。
问题:如何延长脚本执行时间-超过120秒?
PS:以上所有内容(max_execution_time,.)根据指定的收集器更改(如phpinfo()所示)。但是参数realpath_cache_size和realpath_cache_ttl (在编写的phpinfo()等于120)不会改变。也许在这方面有问题?
发布于 2018-10-06 12:27:52
实际上,只要您将代码添加到代码的顶部,您的代码就会运行。
set_time_limit(0);如果您想继续等待输出,则需要设置Apache2超时限制,以及浏览器超时限制。
https://stackoverflow.com/questions/52678985
复制相似问题