1

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.com/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.com/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.

migrated from serverfault.com Mar 23 '15 at 23:48

This question came from our site for system and network administrators.

  • 1
    Having > /dev/null 2>&1 after any command is going to not have any output. What do you think it's supposed to mean? – yoonix Mar 23 '15 at 22:48
  • Yes I know, but the problem is that with this line seems to not execute the wp-cron tasks... – Gixone Mar 23 '15 at 22:58
  • 1
    I'm not following, you said you have problems with wp-cron and are using the system cron. What are you actually trying to solve here? – yoonix Mar 23 '15 at 23:01
  • I want to know why the system cron doesn't execute the wp-cron tasks when that command is executed – Gixone Mar 23 '15 at 23:26
3

Do 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.com/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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.