In this post, we’re going to take you through everything that you need to know about WP-Cron.
We’ll find out what WP-Cron is, how it works, and how you can view all the WP-Cron jobs on your WordPress website. We’ll also share some of the reasons why you might want to disable WP-Cron and replace it with your own time-based system Cron. Then, we’ll conclude by showing you exactly how to do that in cPanel.
Let’s get into it!
What is WP-Cron?
WordPress uses WP-Cron to handle scheduled time-based tasks in WordPress. So, if you schedule a post in advance to publish next Wednesday at 8 pm, WP-Cron is responsible for making sure that the post actually goes live at that time. So, WP-Cron handles all such time-bound or time-sensitive tasks in your WordPress Dashboard.
WP-Cron is essentially what makes any time-sensitive task function on time. It’s named after the Cron scheduling system on Unix-like operating systems. You can run tasks automatically on a schedule that you set with this system-level Cron.
But, WP-Cron is separate and distinct from those tools. Interestingly enough, 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, WooCommerce has lots of backend processes that rely on WP-Cron to run.
How does the WP-Cron work?
WP-Cron relies on visits to your site to function. This leads to one of its biggest shortcomings. Every time you or someone else visits your WordPress site, WordPress runs wp-cron.php and checks for any scheduled tasks. WordPress then goes on to process the scheduled tasks, if any. But, if there are no visitors, there’s nothing to trigger those tasks. This means that those tasks won’t execute until there’s a visit.
How to view WP-Cron jobs?
You can see and manipulate all the tasks that WP-Cron handles on your WordPress site using a plugin. WP Crontrol is a really neat and free plugin that can help you view WP-Cron jobs.
Install and activate the WP Crontrol plugin from WordPress.org. Once it’s installed, go to Tools > Cron Events. Here, you’ll see all the scheduled tasks on your WordPress site and how often/when they run. You can also manually run them if needed.
In the Cron Schedules tab, you’ll see all the different time schedule intervals, and you can even create your own If you want to know where a schedule comes from, just hover over it and WP Crontrol will display the relevant information.
Lastly,you can also create your own Cron events from the Add Cron Event or Add PHP Cron Event tabs.
Reasons to disable WP-Cron
Not Always Reliable
WP-Cron requires visits to work. This is one of its biggest limitations. Moreover, these could be front-end visits from other users or your own visits while you’re working in the dashboard. Irrespective of everything, WP-Cron needs visits to function. Your scheduled tasks won’t run without visits.
A high-traffic site, most likely, won’t face this issue. This is because you’ll always have people landing on your site which will make WP-Cron run. But it can cause real problems for low-traffic sites.
Let’s understand with an example. Let’s say you schedule a post to go live at 3 PM, but your site doesn’t receive any visitors until 7 PM. That means the post won’t go live until 7 PM because that’s the first chance that WP Cron has to execute those tasks.
This limitation might not be a big deal for blog posts, but it’ll also affect all the other time-based tasks on your site like updates, backups, and more.
With a real system-based Cron, you can configure it to trigger tasks every X minutes like clockwork. Now, it’ll trigger tasks whether or not your site has visitors.<span= id=”performancecorn”> This is a more predictable and reliable way to handle time-bound or time-sensitive tasks.
Might hurt performance
The first limitation doesn’t really apply to a high-traffic site. If you get visitors all the time, WP-Cron will have plenty of chances to run and won’t miss any tasks.
But that leads to another potential problem, that is, performance. By default, wp-cron.php fires on every single page load, and it can be a drag on performance. WordPress tries to limit this by not sending additional requests more than once per 60-second period. But, if your site gets multiple simultaneous requests, it can still lead to multiple requests to wp-cron.php.
Moreover, it’s highly unlikely that your site has tasks that must run every 60 seconds. You can surely use a less frequent schedule, like every 15 minutes, and it’ll still be fine.
How to disable WP-Cron and replace it with your own system Cron
By disabling WP-Cron we do not mean that time-based tasks will stop functioning on your site. We mean that instead of relying on visits to trigger WP-Cron, you can use a more reliable time-based system.
With your own system Cron, you’ll also be able to set the frequency as per your needs. Running it every 15 minutes is a good starting point. But, if you’re on a budget hosting, you might want to go to every 30 minutes.
Once set to 15 minutes, your site will execute all of the time-based tasks every 15 minutes only. Irrespective of the number of visits you get, your tasks will still fire every 15 minutes.
There are two parts to disabling WP-Cron:
- Disabling WP-Cron in your wp-config.php file.
- Setting up your own system Cron to load wp-cron.php on the schedule that you set.
We recommend that you back up your site before going any further because you’ll be making changes to the wp-config.php file.
1. Disabling WP-Cron in your wp-config.php file
After creating a backup of your website, connect to your site via FTP or a 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. */:
2. Set up a system Cron
After disabling WP-Cron, you need to set up your own system Cron to run wp-cron.php. If you don’t do this, none of your WordPress website’s time-based tasks will run.
The process to do this depends on your hosting, but we’ll show you how to do it in cPanel. You can reach out to your host’s support for help in case if you’re stuck.
First, look for the tool called Cron Jobs, or something similar and open it.
You’ll see an interface that not only lets you set up a schedule for your Cron job but also the command that you want to run. In cPanel, use the Common Settings drop-down to choose a schedule. In case if that’s not available, you’ll have to follow Cron syntax for setting up the schedule. If you’re following Cron syntax, use Crontab.guru to easily generate the needed syntax.
If you’re on a budget hosting, running it every 30 minutes is a good starting point. You can go more or less frequently depending on your needs. Usually, most sites don’t need to run it any more often than every 15 minutes.
After setting up your schedule, enter the following code in the Command section:
wget -q -O – http://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
(Replace https://yourdomain.com with the actual domain name of your website)
Now, click Add New Cron Job and you’re all set. 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.
We recommend installing WP Crontol to ensure that your scheduled tasks are working. WP Crontrol will highlight any task that is not able to run.
WP-Cron controls time-based tasks on your WordPress site. But, the default way that it functions can be unreliable for low-traffic sites and cause performance issues for high-traffic sites. That’s why you should consider disabling the default WP-Cron and replace it with your own time-based system Cron.
Got any questions? Let us know in the comments below or write to us and we’ll get back to you!
23 thoughts on “What is WP-Cron? How to disable it and replace it with your own system Cron?”
Thanks for sharing, this is a fantastic blog. Really thank you! Awesome.
Appreciation to my father whho shared with mme about this blog, this webpage is in fact remarkable.
I visit daily a few sites and websites to read articles, however this webpage offers quality based posts.
I view something really interesting about your site so I bookmarked.
You completed certain nice points there. I did a search on the matter and found a good number of persons will go along with your blog.
We can see your skills within the article you write. Good Work, Keep it Up!
Great blog right here! Also your web site lots up very
fast! What host are you using?
I want my website loaded up as fast as yours.
I amazed with the analysis you made to make this actual put up extraordinary.
I’m definitely happy I found it and I’ll be book-marking and checking back frequently!
I was able to find good information from your articles.
I’m really impressed with your writing skills
and also with the layout of your blog.
Keep up the excellent quality writing, it is rare to see a great blog like this one today.
An excellent site I have got here.. It’s hard to find good quality writing like yours nowadays.
I truly appreciate people like you! Take care!!
It’s a remarkable article in favor of all the web people; they will obtain benefit from it I am sure.
This blog post is awesome!!
I don’t know who you are but certainly, you’re going to be a famous blogger. Cheers 🙂
What’s up, I read your new stuff on a regular basis. Your story-telling style is witty,
keep it up!
Excellent post. I was checking constantly this blog and I am
impressed! Very helpful information particularly the last part 🙂 I care for such information a lot.
I was looking for this particular information for a very long time.
Thank you and best of luck.
These are really impressive ideas in regarding blogging. You have touched some pleasant things here. Any way keep up wrinting.
I do not even know how I ended up here, but I thought this post was great. I do not know who you are but certainly you are going to a famous blogger if you are not already 😉 Cheers!
I love what you guys are up too. Such clever work and coverage! Keep up the terrific works guys I’ve incorporated you guys to blogroll.
Good blog post. I certainly love this website.
Keep it up!
Hello There. I found your weblog using google. That is a very smartly written article.I will be sure to bookmark it and return to read extra of your useful info. Thanks for the post. I will definitely comeback.
Thank you! What if my website has a sub-domain? do I need to do anything differently?
If someone wishes to be updated with the latest technologies then he must pay a visit to this web page and be up to date daily.