One of the biggest support requests we see with WordPress has to deal with the wp-cron process.
WP-Cron manages all the scheduled events in your WordPress website. It’s a very common cause for high CPU loads and memory consumption especially for websites with very large databases and/or traffic.
By default WordPress is setup to call the wp-cron.php file each time someone hits your website. For most websites this is fine but when you start to get a lot of traffic it can really start to stack up the processes and take a toll on the overall performance of your website.
How to disable wp-cron.php
Thankfully it’s very easy to disable wp-cron.php by just adding a line of code to your configuration file:
- Navigate to wp-config.php file where you have installed WordPress
- Open it up in file manager or your favorite text editor
- Add the following: define(‘DISABLE_WP_CRON’, true);
- Save the file and re-upload.
Now WordPress will no longer automatically run this file when a visitor accesses your website.
Setup wp-cron.php to run manually
Disabling wp-cron.php is going to free up a lot of that CPU/memory usage, but you still need to have it run so WordPress will have the ability to automate any tasks it needs to carry out.
To do this we just need to setup a cronjob inside of cPanel to execute the file:
- Login to cPanel and navigate to Cron Jobs
- Add a new cron job to run once an hour with the following command: wget https://www.yourwebsite.com/wp-cron.php > /dev/null 2>&1
- Make sure to replace yourwebsite.com with the correct URL to your wp-cron.php file.
- Click Add New Cron Job
You’re then all set! WP-Cron will only run once an hour and not when every time someone visits your website.
If you have any questions on this or would like our team to set it up for you, feel free to reach out!
Ryan Gray is the founder and CEO of NameHero, one of the fastest growing independent web hosts in the United States. Ryan has been working online since 1998 and has over two-decades experience in Internet Entrepreneurship.