Right, so I’ve got another useful little tutorial for you. In this tutorial I’m going to show you how to disable wp-cron from running in your WordPress blog or website, and enable it on your server side.
I’m going to be showing you how to do this in SiteGround, that’s the web host I’m currently using myself.
I know there’s a lot of tutorials out there on how to do this for a bunch of other popular web hosts, but there isn’t one done using SiteGround.
Why should I disable wp-cron in WordPress anyway?
Before I get into this, let me first share with you the ‘one single reason’, why you might want to disable the wp-cron from running in the background of your WordPress site.
- wp-cron throttle’s CPU usage like nobody’s business.
Yep that’s right, amongst other things of course.
You might not notice this immediately, but because wp-cron runs on more occasions that most people would want it to, it can create some problems and increase server load time, which of course isn’t good for anybody’s business right?
If you log into your cPanel in your SiteGround hosting account, then scroll down the page until you see the CPU Time Usage. Then if you click on the detailed stats link, then navigate to switch to ‘view CPU Usage graph’, you’ll see the somewhere /wp-cron.php will have a high number of executions. See image below for example.
Now let’s understand something very important here. Cron jobs are important to have in WordPress, especially for doing things like scheduling tasks, blog posts etc.
However, you really don’t need to have it running in the background that often, using up valuable resources. And it doesn’t matter how many visits you get or don’t get to your site either.
OK, so here’s how to first disable wp-cron inside of your WordPress install.
Remember: Always backup your WordPress site, and make copies of any page or file that you’re going to makes changes to. What I usually do is use good old copy-and-paste for the files I’m going to change in my WordPress install. Save a copy somewhere on your desk top should you need to revert to it.
So here goes.
Step One: Disable wp-cron in WordPress
Log into your SiteGround hosting account and navigate to the cPanel.
Then scroll down to Files and click on the File Manager icon, as shown in image below.
A box will appear, click on the Web Root directory, but make sure the ‘Show hidden files’ box is ticked. Now hit Go! See image below.
A new page will open up and will show all the files inside of this directory.
Now navigate to the Public_HTML folder, then find the folder in which the WP files are stored for your WordPress site.
For instance, the files for your WordPress site might be inside the Public_HTML folder, or a sub-folder (Public_HTML folder > sub-folder).
Once you have found the WP files for your website, locate the wp-config file and right click on it. In the drop-down menu, click on the Code Edit link. See image below for example.
Now from the pop-up dialogue box, click on Edit to open up the wp-config.php page.
You should now be inside your wp-config file.
Remember what I said at the beginning of this first step, always backup and make copies of anything you’re going to make changes to. So click to select all the content in the wp-config.php file, then copy, then paste the content inside a blank notepad to save on your desktop just in case you need to revert.
Right, so once you’ve backed up your wp-config.php file, scroll all the way down to the bottom of your original wp-config file inside your public_html folder or subfolder, and in a brand new line, right at the bottom of the page, add the following code.
/* Eliminate nasty background wp-cron */
Once you’ve added this code, simply hit the Save button located at the top right hand side of your screen, then close the page.
You’ve instantly stopped wp-cron from running in the background! That’s the first step, let’s move on.
Step Two: How to enable wp-cron inside your server in SiteGround cPanel
Now we’re going to enable cron jobs to execute on your server side for your website, so that’s the server in your SiteGround hosting.
We’re going to set this to take place twice per-day, instead of multiple times per-day. Of course you can set cron-jobs to execute more than that depending on your needs, but ideally I’d recommend most bloggers have this set to no more than around 4 times per-day. Unless of course you run a multi-author blog, where blog posts are being scheduled more often.
Let’s get to it.
OK so now head back in the cPanel of your SiteGround hosting account, scroll down to the bottom of the page, and under Advanced, click on Cron Jobs. See image below for example.
A new page will open, scroll down until you see Add a New Cron Job.
From the Common Settings drop-down menu, select ‘Twice Per Day’. This will populate the fields automatically for you. Like I said earlier, if you want your cron jobs to happen more, simply change the ‘hour settings’.
Now inside the Command field, enter the following path:
cd /home/<span style="color: #ff0000;">hostingusername</span>/public_html; php -q wp-cron.php
Don’t forget to replace the red part with your own SiteGround cPanel username, which you can find under ‘information and settings’ on the homepage.
Once you’re done with this part, simply click Add New Cron Job.
You are done and dusted my good friend.
You’ve now taken one smart step closer to reducing CPU usage and place less stress on your server. This little trick has worked wonders for me, and I do hope it works for you too.
Final quick notes
If you have more than one WordPress install on your shared hosting account with SiteGround, you’ll have to do this for each of your website. Don’t forget to keep an eye on your CPU usage graph to ensure that what you’ve done is working for you.
Once again this little tutorial was created for folks using WordPress hosted on SiteGround.
If you have any questions or comments, please leave them below as always.
Enjoyed reading this post? Found it useful? I hope so. If you want to get more tips and tricks delivered straight to your email inbox, hit this link to subscribe to my email newsletter.