Home WordPress Using a Real WordPress Cron Job for Increased Reliability

Using a Real WordPress Cron Job for Increased Reliability

by admin

Sometimes it is useful to setup a real cron job to ensure that scheduled WordPress core and plugin maintenance gets done. There are things that happen automatically behind the scenes that keep your site running as expected (publishing scheduled posts, for example). This usually works fine but in some cases tasks may not run reliably. Here’s how to solve that.


What is a Cron Job?

I’ll just say this instead of pasting some semi-technical block of text from Wikipedia.

Scheduled stuff happens automatically.

A cron job needs to be setup manually. In most cases, you log into your hosting control panel and schedule a command to be executed at certain times (every 15 minutes, midnight, Tuesdays, etc.). A standard installation of WordPress doesn’t use a real cron job.

Why Use a Real Cron Job?

I’m writing this tutorial because I learned that caching plugins can naturally interfere with WordPress’s ability to automatically run its scheduled tasks. Our Church Content plugin has recurring events (nobody wants to re-enter Sunday Services every week) and I found that the dates on these events were not automatically moving forward every time. I wanted to keep using the caching plugin so the solution was to force the scheduled tasks to run by setting up a real cron job.

Instead of having users setup a real cron job during installation, WordPress has a sort of “virtual cron” feature. Basically the way it works is that you have visitors to your website and periodically one of these visits causes WordPress to ask itself, “should I run some task?” and if the task is due, it runs. This works in most cases but using a real cron job to trigger WordPress tasks is more reliable, especially on low traffic sites (no visitors to trigger tasks) or if you’re using a caching plugin (no trigger since a cached copy is served).

Setup a Real Cron Job for WordPress

I will use cPanel in this example since there is a very good chance your web host uses it. Setting up a cron job with other hosting control panels such as Plesk should be similar (in some cases the feature may be called “Scheduled Tasks” or similar). If your host doesn’t let you manage cron jobs, try a free cron service.

  1. Log into cPanel
  2. Under Advanced, click on Cron jobs
  3. Under Add New Cron Job, choose “Once an hour” for Common Settings
  4. Enter this for Command (changing the URL to match your site):
    wget -O /dev/null http://yoursite.com/wp-cron.php?doing_wp_cron
  5. Click Add New Cron Job

cPanel WordPress Cron

What this does is trigger WordPress’s wp-cron.php script every hour (you can make it more frequent). Any tasks that WordPress has scheduled to run will run (publish a scheduled post, see if my plugin’s recurring events need to be moved forward, etc.). You are no longer relying on WordPress’s “virtual cron” to be triggered upon a site visit.

Disable WordPress “Virtual Cron”

I have not found this to be absolutely necessary but you can do this to disable WordPress’s attempts to run “virtual cron” when visitors access your site. At the very least this will reduce the load on your website. This may be worthwhile for very high traffic sites.

Simply edit your wp-config.php file to add this:

define( 'DISABLE_WP_CRON', true );

What About Multisite Networks?

If you’re running a multisite network installation of WordPress you’ll need to setup a real cron job for each site, including the main network site.

Main Site

The URL to use for the main network site would be:



The URL for each subsite would be like one of these, depending on if you use subdirectories or subdomains.



You would make a cron job for each subsite in addition to the main network site.


This is usually not difficult to setup but I found few guides out there that I was comfortable linking our customers to, so I wrote this. Hopefully this has been useful to people using caching plugins or that have other reason to force cron to run on WordPress. Please post a comment if you have any suggestions to make this guide more useful.

Related Resources

  • Debug Bar plus Debug Bar Cron will show you which events WordPress needs to run
  • Scheduled Events Using WordPress Cron provides a very in-depth look at how WordPress scheduled events work

Related Posts