If you’re familiar with WordPress, you’ll know that there is a really handy feature that lets you schedule your posts to be published in the future. This is a real time saver if you queue up lots of blogs.
But that’s not the only thing WordPress uses scheduling for. Behind the scenes, WordPress performs tasks like system health checks, general housekeeping, plugin and theme updates on a scheduled basis.
Scheduled tasks in WordPress are activated by something called WP-Cron. In WordPress’ own words:
“WP-Cron works by checking, on every page load, a list of scheduled tasks to see what needs to be run. Any tasks due to run will be called during that page load.”
However, you may have sometimes noticed, especially if your site is relatively new or small, that scheduled tasks don’t always happen at the time you were expecting them to.
Why is that?
The key thing to note in WordPress’ description above is that WP-Cron works on every ‘page load’. This means that someone (or something – for example a search engine spider or bot) needs to visit a page of your WordPress website in order for any scheduled tasks to happen.
When your site is visited, WP-Cron runs and checks a “queue” of scheduled events. If there are any events that were meant to occur since the last time WP-Cron ran, it will take action and trigger all of the events.
If you have a blog post scheduled to publish at 17:35, but no one visits your site until 17:41 – the scheduled event will instead happen at 17:41. Therefore, your blog post will be published at 17:41.
You might be comfortable with this, but if you’re really keen that your scheduled tasks happen at exactly the right time then you need to ensure that your website gets visited regularly.
What can I do to fix this?
While there are a number of complicated server side setups that can do this for you, we get around this issue by using Uptime Robot.
UptimeRobot is designed to check your website frequently to make sure it is online. If it’s ever down for any reason it can send you an email.
Using Uptime Robot you can check up to 50 websites every 5 minutes for free. If you’re happy to pay a little, their Pro Plan allows you to up the frequency to once per minute.
While we use Uptime Robot to check the availability of our client’s web site, it also comes with the fringe benefit that it is constantly visiting your web site and triggering any cron events on time.
Once set up, your site is guaranteed to get “page loads” much more frequently, which means that your scheduled tasks should be more accurate, and overcomes the issues of scheduled tasks not running to schedule.
There are alternatives, such as enabling alternate Cron or using a plugin, but we find using a web site monitoring tool as the optimal way to ensure scheduled tasks stay on track.
Do you want to schedule the release of online lessons for your learners? Send scheduled emails before, during and after your training? Cohort Manager for LearnDash lets you set up engaging cohort-based courses in a matter of minutes.