In this tutorial, I’m going to show you how to easily disable ‘wp-cron’ from running on your WordPress blog or website, and enable it on your server side.
The web host provider I’m currently using is SiteGround, however, it doesn’t really matter which host you use, this tutorial should more or less work the same for all other hosts. At least the ones that offer a CPanel anyway.
Before I get into this tutorial, let me first share with you the ‘one single reason’, why I think you might want to disable the wp-cron from running in the background of your WordPress site.
Yep, that’s right, amongst other things of course.
You might not notice it immediately, but because wp-cron runs on more occasions than most people would want it to, it can create some real problems and actually 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 that somewhere /wp-cron.php will have quite 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. You can’t really completely disable it or have it not run at all.
That being said, you really don’t need to have it running in the background that often, using up valuable hosting resources. And, it doesn’t matter how many visits you get or don’t get to your site either, wp-cron will still use up your resources more often than it should.
OK, so first here’s how to disable wp-cron inside of your WordPress install.
(Disclaimer): 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. I will not be held responsible if your site crashes due to you following the steps below.
So here goes.
Log into your SiteGround hosting account and navigate to the cPanel.
Once again, if you’re using a different web host provider such as Bluehost or HostGator, this tutorial should more or less be the same for those too.
Then scroll down to Files and click on the File Manager icon, as shown in the 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 on 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 located 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. If you don’t have a backup plan, click here.
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.
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, or whatever host you’re currently using.
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.
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 often, simply change the ‘hour settings’.
Now inside the Command field, enter the following path:
cd /home/hostingusername/public_html; php -q wp-cron.php
Don’t forget to replace the ‘hostingusername’ 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.
And that’s it! You are done and dusted my good friend.
You’ve now taken one smart step closer to reducing CPU usage and throttling, and place less stress on your server. This little trick has worked wonders for me, and I do hope it works for you too.
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 websites. 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 is for anyone using WordPress hosted on SiteGround.
If you have any questions or comments, please feel free to send me an email here.
Need a WordPress developer or specialist to take a look at your WordPress site or blog? Click here to get started.
Thanks for reading, more tutorial posts coming soon.