First baseman C.J. Cron hit a 472-foot homer, and a double, en route to a 3-for-3 day. Over his last 11 games, he’s 15-for-30 with three doubles, one triple and four home runs. Cron tasks may also fire when a user visits the site, adding additional action calls. This list should be viewed as a guide line or approximation of WordPress action execution order, and not a concrete specification.
How to improve the performance of your WordPress website should be on the top of your list. Overall performance is important for the website for a number of reasons. You want the site running fast, and you need to have it properly optimized. One of the best ways to improve performance on a website is to disable cron.
What Are Cron Jobs in WordPress?
WP-Cron is how WordPress handles scheduling out time-based tasks. A number of very important core features in WordPress use WP-Cron. These will include but are not limited to:
- Checking for Updates
- Publishing Scheduled Posts
- Backup Plugin Running on a Predefined Schedule
The “Cron” part of the name WP-Cron comes from the cron time-based task scheduling system that is available on UNIX systems.
Basically, WP-Cron works by checking, on every page load, a list of scheduled tasks. This way it can see what needs to run. Any tasks due to run will be called during that page load.
Note: WP-Cron does not run as constantly as the system cron does. It is only triggered on page load.
Why Use WP-Cron?
Even though WP-Cron PHP can have an effect on the overall performance of your website, there are still several good reasons to use it. Honestly, unless your website deals with very high traffic, you probably don’t need to worry about how often the system runs.
That being said, you do have the ability to disable cron in WordPress whenever you want. Before I show you how to do that, let’s look at some good reasons to use WP-Cron.
- The WordPress core and many plugins need a scheduling system to perform time-based tasks. Cron jobs get this done.
- Using the WordPress API is a much easier way to set scheduled tasks than going outside of WordPress to the system scheduler.
- With WP-Cron, all scheduled tasks are put into a queue and will run at the next opportunity. The next opportunity really means at the next page load.
Note: There is no way to be 100% sure when the task will actually run. However, you can be 100% sure that it will indeed run.
Why Does WP-Cron Cause Performance Issues?
WP-Cron is the built-in cron handler for WordPress. Many high traffic and high demand and interaction websites may find they have issues with this. See, WP-Cron is not a real cron job. Instead, it is the system WordPress has created to mimic what a system cron does.
And while sites with high traffic can have issues, sites with very little traffic can suffer performance issues as well. This is because when not many people are loading a page, then a schedule has a higher chance of being missed.
A solution to this is to disable cron and then use the system cron instead. This will help you better run a predefined schedule.
With that being said, let’s take a look at how to easily pull off a WP-Cron disable method. I will also show you how to create a cron job using cPanel after WP-Cron has been disabled.
How to Disable WP-Cron
In order to disable WP-Cron, you need to access the wp-config file for your website. To do this, log into cPanel and click on the “File Manager”icon.
Once inside the file manager, click on the “public_html folder” and then search and open the wp-config file.
Go ahead and open the wp-config file and add this line into it:
You want to add this down at the bottom of the file around line 68. Right before the end of the file. See where I added it in the following screenshot.
Once this is added, go ahead and save the file and you are good to go. At this point, WP-Cron has been disabled.
You can choose to just move on from here, as we have disable cron in order to improve performance. However, it is still a good idea to create cron jobs and make sure certain tasks are being handled.
You can create your own channel and have total control. Let’s take a look at how together.
Note: Make sure you disable the default WP-Cron first, as we did together above.
Create a Cron Job in cPanel
In order to create your own cron job, you will need to log back into your cPanel. If you are still in there because you just accessed the wp-config file, great.
Scroll down to the “Advanced” section of your cPanel and click on the “Cron Jobs” icon.
You will see there is an “Add New Cron Job” page now. Go ahead and add in the settings you want under the Common Settings area. There are several predefined schedules to choose from. These will include options like twice per day, once per week, and many more.
Simply choose the one you want and the box will auto-fill.
Finally, you need to add the following line of code into the command line:
You want to replace the https://domain.com portion with your domain. So don’t forget that.
You can see it done here in the screenshot as well.
Note: This command could vary slightly based on how your hosting is configured.
Now click on the “Add New Cron Job” button and you are good to go.
That’s it! You have successfully added your own cron job using cPanel.
Easy Cron
Lastly, if you are not comfortable with creating your own cron jobs in cPanel, or if your web host does not provide you with that access, then you have another option. You can use a solid third-party solution like Easy Cron.
This solution is a great alternative to what we did above. They will give you all the tools necessary to perform all the cron functions you need. Give them a look if you are not comfortable with what we went over together above.
It is basically allowing you to perform all the same functions, but giving you an easier way than to make the changes yourself.
Final Thoughts
There is a lot to think about if you want to disable cron in WordPress. Yes, your site may run smoother, but you still need it to perform certain functions. For this reason, it is a good idea to create your own cron jobs in cPanel or by using a third-party solution.
I showed you how to not only disable cron, but also how to create your own cron jobs using cPanel. Furthermore, if you are not comfortable with that, then you can check out the suggested Easy Cron solution.
I hope this tutorial has shown you how easy it is to disable cron in WordPress in order to improve performance. You may need to do some research or go slowly through the process if it is your first time, but you will get there.
Not everything in WordPress can be handled with a plugin. While this method is definitely preferred, in some instances you need to have knowledge of your website files, how to access them, and how to configure certain options.
Have you disabled cron on your WordPress site before? Have you found that there is a link to that and better overall performance?
Author: Jeremy Holcombe
Growing up in Hawaii, Jeremy started his freelance writing career doing resumes, business plans, article writing, and everything in between. He now specializes in online marketing and content writing and is part of the Content Marketing Team at GreenGeeks.
Was this article helpful?
Related Articles
Let's talk about robbing a bank
Imagine a team of thieves who are set to rob a bank. They've hired a driver to pick them up at an appointed time. The exact time that they'll walk out of the bank.
They then enter the bank and have set their stopwatch. They have 180 seconds to get everything they can and walk back out – in order to beat the cops to the bank. And in 180 seconds (three minutes), their driver will drive up and pick them up.
In a situation like that, if you're one of the bank robbers, you want to make sure that everything goes according to plan, right?
But what if I told you that the driver's watch worked differently than other watches? What if I told you that his second hand moved only when he was on his cell phone? Or only when he moved his arm? Or only when he smoked a cigar?
Not a very reliable watch, right? And if that's not reliable, could you count on him to come get you at the right time?
I didn't think so.
Let's talk about WP-Cron
We'll get back to our bank robbers in a just a second. But first let's cover what Cron is.
It's actually the name of a command from the old Unix days where you could schedule a future event to happen at a specific time. That's pretty handy, right? Imagine you wrote some logic but you only wanted it to happen at midnight. Then you'd put that code in a spot and only call it every night at midnight, using Cron.
So you can then imagine that WP-Cron is like that. And it is. Except where it's different.
WP-Cron is Cron for WordPress. And here's the thing – every server that runs WordPress is different. So that means that implementing a low-level set of commands that will work on any and every environment is pretty darn tough.
So WP-Cron doesn't work that way. It's not based on the server, or the server's clock.
Instead, there's a check every time a person calls one of your pages or posts. Every time WordPress goes to work, it checks to see if there are any jobs that need to leverage WP-Cron.
But that's a bit precarious, as you might imagine. Especially for sites that don't get hit very often.
In other worlds, WP-Cron works fine for sites that get a decent amount of attention, but not necessarily as great for those sites with little to no traffic.
In this way, WP-Cron is like having a driver with a watch whose time is dependent on something other than the normal second passing. Instead, it's tied to a variable (like arm movement). In your case, the variable is a request (as in a call to a post or page).
So is WP-Cron great for large sites?
Since I told you it wasn't great for small sites, you're likely thinking that it's awesome for large sites because they're always getting traffic. And that would mean that processes would get called any and all the time.
That is true. But that is also its potential issue on highly trafficked sites. Because every request can spawn a process that goes to work and takes up server resources. Imagine spinning up several (a lot) of server processes all concurrently. That might easily bring your server down if you don't have adequate resources.
So in the end, I don't like WP-Cron for small sites. And I don't like it very much for large sites.
I prefer a regular cron job. Something that's scheduled using a normal clock.
Here's what I use instead of WP-Cron
Wordpress Cron Job
A few years ago we decided to make some nightly routines in our real estate solutions that use WordPress. And that's when we decided to move from WP-Cron to something else. Our something else is called SetCronJob – and it's an online service.
The service works regardless of what kind of server I'm hosting with, which is helpful for us. It also is really easy to schedule and control. And lastly, it's inexpensive (and free for some folks).
Wordpress Cron External
We've been using an externalized cron service now for 30 months and have absolutely loved the simplicity and consistency of the service.
Because, if you're going to rob a bank, or do anything even more important, you want the guy who's helping you to have a watch that works – all the time, every time.
And that means I need an external cron service like SetCronJob. Check it out!