Menu
Web Design | SEO | Website Development

UK Based Web Agency, Magento & Wordpress Specialist (Cranleigh | Surrey)

WordPress Cron Disabled by Optimisations Fixed

By In Platforms, SEO, Website Development On 27/08/2014


After doing many optimisations for PageSpeed on the website you are using to read this post (evince.uk) I realised that the WordPress scheduler wasn’t working as it should – I noticed this because when I went to check my scheduled backups were working (I use UpdraftPlus for this) a message popped up to say that there were several events that should have happened and it was an issue – a very useful little popup, which I was grateful for as the scheduler does lots of useful things in the background. The standard WordPress scheduler is activated when the site is accessed from the front end which isn’t great in itself, something needed to be done.

I’m not exactly sure what killed the scheduler but some of the major things I did was using The Cloudflare Content Delivery network (CDN), having SSL installed using WordPress HTTPS & W3 Total Cache, it could be one or all of these. After several weeks of tweaking I have managed to get a 98 Page Score on both Mobile and Desktop, given that I wasn’t too keen on moving the site out of its sweet spot.

After reading this article provided by UpdraftPlus I tried the alternative cron by adding this to the wp-config.php file: define(‘ALTERNATE_WP_CRON’, true);

Which works but made ugly URLs by appending a URL parameter ?doing_wp_cron=*** – I also had to configure Google Webmaster Tools to ignore this parameter.

To fix the issue and to not have to use the alternate cron I ended up by disabling the standard virtual cron and setting up my own cron in cPanel:

  • My first step was to add specific wordpress page rule to Cloudflare, go to: Page Rules add *yoursite.com/wp-* into Add new rule then set custom caching to Bypass Cache. Now set up a second rule *yoursite.com/* and set custom caching to Cache everything
  • Go to wp-config.php, add define( ‘DISABLE_WP_CRON’, true ); to disable the standard cron (I understand that this has an added benefit of not being triggered upon frontend access which give a small optimisation boost). Make sure you don’t have define(‘ALTERNATE_WP_CRON’, true); in there too
  • Go to cPanel | Cron give a command for a cron to run every 15 minute (which is OK for my site, but you may want it more often or less frequent given your specific requirements)

*/15     *     *     *     *     php /home/$USER/public_html/wp-cron.php


About the Author

Dan Vince

Yet another Web Development Professional

Related Posts

3 Comments

  • Sage 3 YEARS AGO

    Great post. If you don't have cron jobs on your server you can always use https://www.easycron.com/

    Reply
  • William 2 YEARS AGO

    I am having issues with running cron jobs from our website and I did everything described above but it did not work for me. I suspect that it is because our cron job must be run with "curl" as opposed to "php". Do you know a way around this? Thanks.

    Reply
  • Dan Vince 2 YEARS AGO

    Howdy I've been using this recently. Which also stops emailing the notification every 15 mins. Obviously change the URL to your own.*/15 * * * * wget -q -O - https://www.evince.uk/wp-cron.php?doing_wp_cron > /dev/null 2>&1

    Reply

Leave a comment