Site Speed WTF?!

Weekly Email

Please wait…


You have subscribed! A verification email will be sent to you.


SpeedGuard tracks Core Web Vitals from your WordPress. Check it out.

WordPress CRON Job setup tutorial for CPanel

WordPress CRON Job setup tutorial for CPanel
If you have bumped into that nasty Missed Schedule issue on your website ->>> you might want to check this post first.

What is wp-cron.php?

To answer this question we should understand what CRON itself is. Cron is a time-based job scheduler in Unix-like systems (which means most hosting providers got it). These are typical cron jobs examples:

  • check for software updates every day at 1 am
  • make user’s databases backup twice a day
  • scan directories for malware every Monday

In other words, when you want to do something on a regular basis cron is what you use. Whenever the task is scheduled to run on your server it will be executed automatically without any actions from the user or system administrator.

WordPress comes with its own cron system which handles all recurrent tasks. Such tasks as checking core, themes, and plugins updates are set by default.
These are typical WordPress Cron jobs examples:

  • publish pending posts twice a day
  • check whether the user’s paid subscription is active and change his role accordingly every day
  • delete revisions daily

You can schedule any event you want to happen at a certain interval. But WordPress Cron doesn’t work the same way UNIX cron does. It’s much more like a simulator, though convenient, flexible, and useful but still not a real cron job.

What does wp-cron do?

As you remember UNIX cron is a time-based system that will fire exactly at a predefined time no matter whether someone is visiting the website or not.

WordPress cron doesn’t work like that.

It triggers on page load only. When someone visits any website page it fires and checks all scheduled tasks time. And if the scheduled time has already passed the task is executed. See the difference?

That means if you scheduled your post to publish on 7:32 am and your website traffic is not that big, your post most likely won’t be published exactly on that time. If the first visitor will attend your website at 8:40 am just then you’ll get it published. Someone has to visit your website to trigger WordPress CRON.

This WordPress Cron peculiarity can cause some problems for new or not that popular websites. On the other hand websites with a load of traffic may face another problem. As WordPress CRON is triggered on every page view it may cause a high CPU load and lead to serious performance issues.

No panic! We can manage it! What we gonna do is

Replace WordPress Cron with a real Cron job in 3 steps

We’ll set up UNIX cron to handle our tasks instead of WordPress Cron in three steps:

#1 Disable wp-cron in WordPress wp-config.php:
define('DISABLE_WP_CRON', true);

#2 Set a real cron job instead:

  1. Navigate to Cron Jobs in your CPanel
  2. Add new cron job command
wget -O /dev/null http://yourwebsite.com/wp-cron.php?doing_wp_cron

and set the time (Common settings already have the list). If you set a 1-minute interval that means the system cron will trigger your WordPress cron every single minute which guarantees your scheduled tasks are executed exactly at the scheduled time. But also it means a significant server load. That’s why if it’s ok with your tasks to have some delay think of larger intervals, say 5 minutes or even once an hour.

See your tasks done!

That was pretty simple, wasn’t it? Setting a real cron job instead of a WordPress built-in cron can reduce server load and forget about missed schedule issues forever.

Leave a Reply

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