This was a little fault that I found in my development environment, which I’ve recently moved onto my Heart Internet hosting as explained the other day.

The issue is specific to Heart Internet’s hosting and results in any scheduled jobs not running!  Scheduled jobs could include automatic updating, database cleaning and posting of scheduled posts, but could also include other features provided by plugins, such as automated database backup.

wp-cron – how WordPress does scheduled jobs

WordPress normally runs on a Linux or Unix server, and, as such, you could use the “cron” feature of Linux/Unix to run scheduled jobs. BUT…most web hosts don’t let you have access to cron – and rightly do: you could do a lot of damage through incorrect use.

WordPress, though, needs to be able to do some useful scheduled tasks, things like cleaning up deleted items, and publishing posts scheduled for future posting.

So, WordPress uses what is often called “pseudo-cron”. There is a script – wp-cron.php – that runs all the scheduled jobs, and WordPress tries to run this script whenever someone visits your website.  It does this by loading the web page http://<your-domain>/wp-cron.php  It will do this at most once per minute.

You can use a plugin like cron-view to see what’s in your list of scheduled jobs. For me, it was some automated digest emails not sending that brought the issue to my attention!

A Heart Failure

Heart Internet don’t allow a PHP script (or any script) running on its server to make an HTTP request back to the domain that the script is running on. It’s possible, though I’ve not investigated it, that they don’t allow a request back to the server, or to any of their servers, potentially blocking HTTP access to other domains that they host too.

So, the short story is that if you’re running an out-of-the-box WordPress install on Heart, none of its scheduled jobs will work!

I discovered this thanks to numerous forum posts, including this 6-day-old one on the WordPress support forums for a backup plugin.

A Solution

There’s another very helpful discussion over on the WordPress Forums that both explains why wp-cron is implemented the way it is, and offers a workaround: add the following to your wp-config.php

define('ALTERNATE_WP_CRON', true);

The fix is described as “a bit iffy sometimes”, and I’ve not tested it, but I would recommend giving it a go if you’re running WordPress on Heart’s servers.

Another Solution

Another way to tackle this is to make use of the fact that Heart let you run cron jobs anyway, so you can just set up a cron job to run once every 15 mins to run wp-cron.php.  This is probably a better solution but it’s a bit of a pain setting it up for every WordPress install you’ve got…if, like me, you have many!