Skip to main content

What Is WP-Cron? Plus How to Disable WP-Cron in 2020

Wondering what WP-Cron is, whether or not your site needs it, and/or how to disable WP-Cron (I guess that’s kind of a spoiler to the previous question)?

In this post, I’m going to take you through everything that regular WordPress users need to know about WP-Cron.

I’ll explain what WP-Cron is, how it works, and how you can view all the WP-Cron jobs on your site. Then, I’ll share some of the reasons why you might want to disable WP-Cron and replace it with your own time-based system cron. Then, I’ll finish by showing you exactly how to do that in cPanel.

Let’s jump in!

What Is WP-Cron (wp-cron.php)?

In a nutshell, WP-Cron is what WordPress uses to handle scheduled time-based tasks in WordPress.

For example, if you schedule a post in advance to publish next Tuesday at 4 pm, WP-Cron is what’s responsible for making sure that post actually goes live at that time. Or, if you schedule a weekly database cleanup via your favorite database optimization plugin, WP-Cron also handles that.

Basically, WP-Cron is what makes any time-sensitive task function.

It gets its name from the cron scheduling system on Unix-like operating systems. With this system-level cron, you can run tasks automatically on a schedule that you set.

How, despite the similarity in name, WP-Cron is separate and distinct from those tools.

WP-Cron isn’t just for actions that you schedule, either – many WordPress plugins also rely on WP-Cron to schedule their own tasks to run. For example, if you’re using WooCommerce, it has lots of backend processes that rely on WP-Cron to run.

How Does WP-Cron Work?

WP-Cron relies on visits to your site to function, which leads to one of its biggest limitations. Every time you or another person visits your WordPress site (either the backend or front-end), WordPress runs wp-cron.php and checks for any scheduled tasks. If there are scheduled tasks, WordPress will then process them.

But that’s the key – if there are no visitors, there’s nothing to trigger those tasks, which means those tasks won’t execute until there’s a visit (more on this later).

How to View WP-Cron Jobs

If you want to see and manipulate all the tasks that WP-Cron handles on your WordPress site, there’s a really neat (and free) plugin called WP Crontrol. Once you install and activate the plugin from WordPress.org, you can go to Tools → Cron Events to see all of the scheduled tasks on your WordPress site and how often/when they run. You can also manually run them if needed.

My example site is a fresh install of WordPress, so there’s not a ton going on – if you have a lot of plugins, you’ll likely see a lot more tasks:

WP-Cron plugin

If you go to the Cron Schedules tab, you can see all of the different time schedule intervals, and create your own. WP Crontol will also tell you where a schedule comes from if you hover over it:

Schedules

Finally, if you want to get really crazy, you can also create your own cron events from the Add Cron Event or Add PHP Cron Event tabs.

Why Should You Disable WP-Cron?

There are a few reasons why you might want to disable WP-Cron and replace it with a real system Cron (from your server).

1. It’s Not Always Reliable

One of the biggest limitations with WP-Cron is that it requires visits to work. Again, these visits could be front-end visits from other users or they could be your own visits while you’re working in the dashboard. But no matter what, WP-Cron needs visits to function, otherwise, your scheduled tasks won’t run.

If you have a high-traffic site, this isn’t an issue because you’ll always have people landing on your site (which lets WP-Cron run). But for low-traffic sites, this can cause real problems.

For example, let’s say you schedule a post to go live at 5 pm, but your site doesn’t receive any visitors until 8 PM. Well, that means that post won’t go live until 8 PM because that’s the first chance that WP Cron has to execute those tasks.

Now, this might not be a big deal for blog posts, but this limitation will also affect all the other time-based tasks on your site (like automatic updates, backups, cleanings, etc.).

With a real system-based Cron, you can configure it so that these tasks are triggered every X minutes like clockwork, whether or not your site has visitors, which is a much more predictable and reliable way to handle time-based tasks.

2. It Can Hurt Performance

If you have a high-traffic site, the first limitation doesn’t really apply to you. Why? Because if you have people visiting all the time, WP-Cron will have plenty of chances to run and you won’t miss any tasks.

But that leads to another potential problem – performance. By default, wp-cron.php will fire on every single page load, which can be a drag on performance. WordPress does try to limit this by not sending additional requests more than once per 60-second period. However, if your site receives multiple simultaneous requests, this can still lead to multiple requests to wp-cron.php.

Additionally, even with the 60-second limit, it’s still unlikely that your site has tasks that must run every 60 seconds. Usually, a less frequent schedule, like every 15 minutes, is still fine.

Basically, WP-Cron can be problematic for both low-traffic and high-traffic WordPress sites, though for different reasons.

How to Disable WP-Cron (and Replace It With a Real Cron Job)

Now, let’s go over how to disable WP-Cron and replace it with your own system cron.

Just to be clear, this doesn’t mean that time-based tasks will stop functioning on your site. It just means that, instead of relying on visits to trigger WP-Cron, you can use a much more reliable time-based system instead.

You’ll also be able to set the frequency to meet your needs. A good starting point is running it every 15 minutes, but you also might want to go to every 30 minutes if you’re on budget hosting.

If you set it to 15 minutes, your site will execute all of the time-based tasks every 15 minutes no matter what. You could have 500 visits or zero visits – either way, your tasks are still going to fire every 15 minutes.

There are two parts to disabling WP-Cron:

  1. Disabling WP-Cron in your wp-config.php file.
  2. Setting up your own system cron to load wp-cron.php on the schedule that you set.

As always, we recommend that you back up your site before proceeding because you will be making edits to the wp-config.php file.

1. Disable WP-Cron in wp-config.php File

Once you have a recent backup of your site, connect to your site via FTP or something like cPanel File Manager.

Then, find and edit the wp-config.php file, which is usually in the root folder of your site.

Add the following code snippet above the line that says /* That's all, stop editing! Happy publishing. */:

define('DISABLE_WP_CRON', true);

How to disable WP-Cron

2. Set Up Your System Cron

Now, you need to set up your own system cron to run wp-cron.php – otherwise, none of your WordPress site’s time-based tasks will run.

How you do this will depend on your hosting, but I’ll show you what it looks like in cPanel. If you’re stuck, you can reach out to your host’s support for help.

First, look for the tool called Cron Jobs, or something similar:

Cron jobs in cPanel

Now, you should see an interface that lets you set up a schedule for your cron job, as well as the command that you want to run. In cPanel, you should be able to use the Common Settings drop-down to choose a schedule. Otherwise, you’ll need to follow cron syntax for setting up the schedule. In the latter scenario, Crontab.guru makes it really easy to generate the needed syntax.

Again, running it every 30 minutes is a good starting point for budget hosting. You can go more or less frequently depending on your needs, but most sites don’t need to go any more often than every 15 minutes.

Once you’ve set up your schedule, enter the following code snippet in the Command section. Make sure to replace https://yourdomain.com with the actual domain name of your site:

wget -q -O - http://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

Create cron job cPanel

Then, click Add New Cron Job and you’re set to jet! You should see it appear in the Current Cron Jobs section. If needed, you can always edit or delete the cron job from that section:

Manage cron jobs in cPanel

I recommend installing WP Crontol to make sure that your scheduled tasks are still working. If any tasks aren’t able to run, WP Crontol will highlight them. You can ignore the warning about WP-Cron being disabled, though.

And that’s it! You just officially disabled WP-Cron and replaced it with your own system-based cron job.

Can’t Set Up Cron Jobs On Your Hosting? Use a Third-Party Service

If you’re unable to set up cron jobs on your web hosting, or if you’re just generally confused by your host’s interface, you can also use a third-party service. Some popular options are:

All you need to do is use one of these services to run the same command from the previous section.

Disable WP-Cron (wp-cron.php) Today

WP-Cron plays an essential role in controlling time-based tasks on your WordPress site. However, the default way that it works can be unreliable for low-traffic sites and can sometimes cause performance issues for high-traffic sites.

For those reasons, you should consider disabling the default system and replacing it with your own time-based system cron.

To do that, all you need to do is follow the steps in this article.

Do you still have any questions about how to disable WP-Cron? Ask away in the comments!

Wp-dd.com

WordPress Design, WordPress Development, cPanel Hosting, Web Design, Web Development, Graphic Design, Mobile Development, Search Engine Optimization (SEO) and more.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.