在我的网站上,Cron作业的速度非常慢。
我在Wordpress环境之外创建了这个小脚本,只是为了测试WP Cron的响应时间:
<?php
//Method which does a basic curl get request
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
//getinfo gets the data for the request
$info = curl_getinfo($ch);
//output the data to get more information.
print_r($info);
curl_close($ch);
return $data;
}
get_data(\'http://www.example.com?wp-cron.php?doing_wp_cron=1486419273\');
结果如下:
Array
(
[url] => http://www.example.com/?wp-cron.php?doing_wp_cron=1486419273
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 42.822546 // Important
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
(
)
[primary_ip] =>
[primary_port] => 0
[local_ip] =>
[local_port] => 0
[redirect_url] =>
)
正如你所看到的,它有一个令人难以置信的加载时间几乎43秒。
以下是Crontol插件报告的我的cron:
我在这里看到的最大问题是;“下次运行”;没有更新,这意味着每个cron每次都会运行。。。这可能就是为什么它这么慢,不是吗?
如何制作;“下次运行”;实际上根据cron的;重复性;?