From using GZIP compression to using WebP images, there are a million ways to speed up WordPress. But if your server is overloaded, then the only way to make your website faster is to reduce the tasks that it has to perform. Here’s how to disable wp-cron.php in WordPress, reduce server resources, and ultimately help speed up your WordPress website.
What Is WP-Cron And Why Should You Consider Disabling It?
Before we show you how to disable wp-cron.php, let’s review a few things first.
What exactly does the wp-cron.php script do? The wp-cron.php file contains a list of scheduled tasks for WordPress. These automated tasks include things like publishing your scheduled posts or checking for updates for plugins or themes.
One server setting, in particular, is the intervals in which the wp-cron.php script is called. By default, the wp-cron.php script is called each time a new visitor comes to your WordPress site. Calling this script multiple times an hour is unnecessary. This can cause high resource usage on your server and crash your site.
Learning how to disable wp-cron.php is easy, but you will need to replace it with a cron task in cPanel. This tutorial will show you how.
NERD NOTE: What exactly does the wp-cron.php script do? The wp-cron.php file contains a list of scheduled tasks for WordPress. These automated tasks include things like publishing your scheduled posts or checking for updates for plugins or themes.
Take WP-Cron Control Away From WordPress
Before you can specify wp-cron settings at the server level, you need to tell WordPress to not worry about it anymore in the wp-config.php file.
- Open your wp-config.php file using either your cPanel File Manager or an FTP program.
- Scroll to the bottom of the database settings in the wp-config.php file. It should be around line #40.
- Add the highlighted line code below on a separate line right after define(‘DB_COLLATE’, ”);
** The Database Collate type. Don't change this if in doubt. */
By default, WordPress will automatically run the wp-cron.php script every time a new visitor comes to your site. By disabling this, you will be giving your server a much-needed rest.
How To Disable Wp-Cron.php And Schedule Cron Jobs
Permanently disabling Cron jobs is a bad idea. You don’t want to prevent WordPress from executing necessary automated tasks. But WordPress doesn’t need to run the wp-cron.php hundreds or thousands of times an hour. Instead, we are going to just have the wp-cron.php script run every 6 hours.
- Log into your cPanel dashboard.
- Under the Advanced section, click on Cron Jobs.
- Select Once per hour from the Common Settings drop-down.
- Next select Every Sixth Hour from the drop-down.
- Type the following line of code in the Command line field and then click on the Add New Cron Job button. Swap out “username” with your actual cPanel username. Also, you may need to change public_html if you are modifying a WordPress install that is not the primary site on your server. The public html directory is the default folder for the main WordPress site on a server. If your site isn’t in the “public_html” folder, that’s perfectly fine. Just change what you type in the Command field to match your folder name.
cd /home/username/public_html; php -q wp-cron.php
- After you add the script, you should now see that your new cron job listed. Please double check each character and make any edits if necessary.
Disable WP-Cron.php Default Behavior: Pros & Cons
WordPress is a very popular Content Management System (CMS). According to W3Techs, about 30% of all websites run on WordPress. But unfortunately, some WordPress default settings are not optimized for higher traffic websites.
If you are using a WordPress caching plugin like WP Rocket to increase page load speeds and still experiencing problems, then it might be time to reduce resource usage on your server by only calling your wp-cron.php script every few hours.
Tweaking your wp-cron.php file is easy. However, if you don’t have access to cPanel, then don’t disable cron. Doing so will cause issues for your site like missed scheduled posts.
Frank Wilson is a retired teacher with over 30 years of combined experience in the education, small business technology, and real estate business. He now blogs as a hobby and spends most days tinkering with old computers. Wilson is passionate about tech, enjoys fishing, and loves drinking beer.