admin管理员组文章数量:1290177
I'm on centOS 7 and I have a WordPress site. Due to some problems with the WordPress default wp-cron settings, I have chosen to do the cron tasks with my server instead. I have used this command:
wget .php?doing_wp_cron=1 > /dev/null 2>&1
to run every 10 minutes. This works, every ten minutes it try to wget that page but it doesn't generate any outputs and the WordPress cron tasks are not executed.
Furthermore, if I try to open the page: .php?doing_wp_cron=1 by myself on my browser, I get a blank page... Is this an error? I don't get any message in the Apache error log.
I'm on centOS 7 and I have a WordPress site. Due to some problems with the WordPress default wp-cron settings, I have chosen to do the cron tasks with my server instead. I have used this command:
wget http://www.example/wp-cron.php?doing_wp_cron=1 > /dev/null 2>&1
to run every 10 minutes. This works, every ten minutes it try to wget that page but it doesn't generate any outputs and the WordPress cron tasks are not executed.
Furthermore, if I try to open the page: http://www.example/wp-cron.php?doing_wp_cron=1 by myself on my browser, I get a blank page... Is this an error? I don't get any message in the Apache error log.
Share Improve this question edited Jan 30, 2018 at 9:14 Glorfindel 6093 gold badges10 silver badges18 bronze badges asked Mar 23, 2015 at 22:45 GixoneGixone 231 silver badge3 bronze badges 4 |2 Answers
Reset to default 4Do you have define('DISABLE_WP_CRON', true);
set in wp-config? You need it to have the system cron fire up the wp-cron tasks. Go to the bottom of the database settings in wp-config.php, typically around line 37, and add it.
Then setup the system cron to fire up the wp-cron tasks:
*/5 * * * * wget -q -O - "http://example/wp-cron.php?t=`date +\%s`" > /dev/null 2>&1
#Sometimes it might be required to run PHP directly:
*/5 * * * * php /home/$USER/public_html/wp-cron.php
?doing_wp_cron
is appended only automatically when you define ALTERNATE_WP_CRON
as true
in wp-config.php
. Since you are disabling it entirely, you want to use the URL above instead or the 2nd method, which dispenses parameters.
If you're on a development environment and want to output debug information, calling it manually like that will show you your debug output.
Alternatively you can use PHP's built-in error_log function to log message strings to the error log for debugging. You'd need to use this in conjunction with WP_DEBUG settings.
If you need further help debugging it, try this question.
For people reaching this page because they use FastCGI and they can't find a way to run wp-cron.php
Issue with FastCGI:
When using FastCGI there is an issue that prevents wp-cron.php to be run from the browser.
To fix it, comment the following lines in your wp-cron.php
:
Remember that it is not recommended to modify core WordPress files, so proceed only if you know what you are doing.
Before:
/* Don't make the request block till we finish, if possible. */
if (function_exists('fastcgi_finish_request') && version_compare(phpversion(), '7.0.16', '>=')) {
if (!headers_sent()) {
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate, max-age=0');
}
fastcgi_finish_request();
}
After:
/* Don't make the request block till we finish, if possible. */
//if (function_exists('fastcgi_finish_request') && version_compare(phpversion(), '7.0.16', '>=')) {
// if (!headers_sent()) {
// header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
// header('Cache-Control: no-cache, must-revalidate, max-age=0');
// }
//
// fastcgi_finish_request();
//}
本文标签: Why cron doesn39t work to me
版权声明:本文标题:Why cron doesn't work to me? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741494263a2381763.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
> /dev/null 2>&1
after any command is going to not have any output. What do you think it's supposed to mean? – yoonix Commented Mar 23, 2015 at 22:48