It is possible to use WordPress for years and not know what WP-Cron is until the day you check your server logs and realize that a process called WP-Cron.php is using up your memory and CPU.
Let’s start by understanding what WP-Cron.php is:
WP-Cron is a script within the WordPress core that takes care of periodical maintenance tasks such as scheduling posts to go live at a future date, and for running Akismet’s spam filter.
If you own a WordPress site that doesn’t have much visitors or has a small number of pages/posts, you will not necessarily notice any problem with WP-Cron.php. However, if you have thousands of page views an hour and have hundreds of pages/posts, you might have an issue with WP-Cron.php and this is mostly because WP-cron.php will run as many times as the number of page views and site activity that you have in a day by default.
While WP-Cron.php is at the core of your WordPress installation, it can however be controlled to only work at certain intervals instead of working at will. This is exactly what you need to do to ensure that it doesn’t use up your CPU and Memory allocation.
Follow the steps numbered below to have your WP-Cron.php run at specifically defined intervals.
- Login to your cPanel
- Click on the file manager option
- Select the wp-config.php and click on edit file
- Insert the following code right after the first line “define(‘DISABLE_WP_CRON’, true);“
- Save the file and exit
- Go to your cron access on your site and create a new cron job
- Enter the following line as the cron command “/usr/bin/wget -O /dev/null http://www.mydomain.com/wp-cron.php?doing_wp_cron”, replacing www.mydomain.com with your site domain
- Set the cron to run once a day if you don’t have much traffic and say every two to four hours if you have lots of traffic
If you do not understand any of the steps below, I will advise you get through to your web administrator to help you with the task as not understanding this steps means that you lack the technical know-how to complete the fix.