Introduction to wp-cron
You have a post that you’ve written, but you want it to be published in a few days. So you set it to be published at another time using the Schedule Event feature:
And… it doesn’t post when you want it to. What happened? Why didn’t it publish? What can you do to understand what happened? How can we help you prevent this from happening again?
The answer to all of those questions begins with understanding the function at the core of this, wp-cron. In this article, we will discuss what the wp-cron does, the common issues with the wp-cron and how we at WP Engine handle scheduling events.
What is the wp-cron function?
The wp-cron is a function that executes scheduled events in your WordPress environment such as looking out for core, theme and plugin updates, publishing scheduled posts like the one above, and much more.
When a page opens on your site, WordPress checks if there is a need to send a request to the wp-cron.php file. If there is a scheduled event, then the cron runs separately in the background instead of delaying load times.
Missed Scheduled Event
This works very well most times, but if the site has low traffic then the cron is not prompted to check for scheduled events and the event is missed.
If you have a low traffic site or if your site is not live and your articles are not published:
- Check your access log by going to your User Portal and navigating to the Overview page for your environment.
- Go to Access logs from the left-hand navigation menu.
- Once in the Apache logs, run a search for “wp-cron.php”:
You will see that a cron was activated in the example. Here’s a closer look at the entry:
184.108.40.206 - - [27/Jun/2017:17:25:27 +0000] "POST /wp-cron.php?doing_wp_cron=1498584326.8485939502716064453125 HTTP/1.0" 200 - "https://wpengine.com/wp-cron.php?doing_wp_cron=1498584326.8485939502716064453125" "WordPress/4.8; https://wpengine.com"
If you don’t see an entry like this, then the cron has not been activated and article did not post.
To remedy this, open a 24/7 Live Chat with us from your User Portal and ask us to activate our alternate cron, which we explain below.
The WP Engine Alternate Cron
The WP Engine Alternate Cron is a true cron that runs every minute on the minute, checking for and activating scheduled events. This is not enabled on your server by default, so you will have to request to have it enabled via Support. Simply open a Live Chat–available 24/7 in your User Portal— to request this. Once it has been enabled, it will ensure that the events are run as scheduled.