WordPress Cron Disabled by Optimisations Fixed

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

  1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

301 a whole site but exclude the robots.txt file

Next Post

Easy Magento Layout Modification Using Custom Layout & CSS

Related Posts