Why wordpress cron fails and how to fix

WordPress has its own cron job implementation that allows you to schedule your posts and events. It was done in a way to be simple and it works in most cases. WP-Cron is not a real cron job, it only works when a page is loaded. When a page is requested, it will then check the database to see if there is anything scheduled and after displays to your reader. However, in some situations, the WP-Cron does not work well and this leads to posts that missed publication schedule and events not executed.  May be you have seen the “Missed Schedule” status.
WP-Cron is to fail for many reasons like:
  • Heavy load in the server
  • WordPress bugs
  • DNS issues
  • Using of caching plugins
  • Plugins conflict
  • Numerous of other reasons
One of the way to solve the WP-Cron issue is to disable WP-Cron and use a real cron job instead.

Disable WP-Cron and use real cron job

By using a real cron job, you can be sure that all your scheduled items are executed. For high traffic blogs and sites using a real cron job can reduce the server load/bandwidth. Reduce the chances of server crash when you are experiencing Slashdot effect. 1. Add this command to be executed once in 5 or 10 minutes
wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Replace http://yourwebsite.com with your website URL. 2. Add to the wp-config.php following line define('DISABLE_WP_CRON', true); You are done. To make sure it works schedule a post in 15 minutes and see if it was published.  

Leave a Reply

Your email address will not be published.