Why and how to disable the WordPress wp-cron.php and set it as a real Cron Job within cPanel?
Knowledgebase Article
}
Knowledgebase Article
WordPress installations will often need to run periodic tasks. As standard, those tasks are executed via the the wp-cron.php script.
This may happen when you’re loading pages in the backend of the website, but it can also happen when clients are navigating the frontend site.
If the wp-cron.php script executes a complex process, such as copying files or optimising images, this can cause the execution of the page to happen more slowly whilst this processes. To avoid this, WordPress can be configured to disable wp-cron.php from executing on page load and instead, have the server trigger this command peridically.
It’s easy to set this up in Softaculous' WordPress Manager.
Navigate to cPanel → WordPress Manager by Softaculous and locate your WordPress installation in the list.
On the next screen, set WordPress Cron to Disabled.
This will disable the cron from running on page execution, and create a cron job in cPanel to execute the WordPress cron twice per hour.
Whilst using Softaculous gives you the simplest way to set this up, if you would prefer to configure this manually, please see the steps below.
Step 1) Disable wp-cron at the WordPress wp-config.php
Step 2) Setup wp-cron as a real Cron job within cPanel
This technique will improve the load time of your website and make sure that wp-cron is running a maintenance tasks never mind if anyone has come to your website or not.
Let's get started!
1) Login to your cPanel and open the File Manager:
then go to the Document Root folder of the website:
2) Right click the wp-config.php and select Code Edit:
Right after he opening PHP tag <?php enter:
define('DISABLE_WP_CRON', true);
then Save the to disable the wp-cron within WordPress:
That's it! You have completed Step 1.
Type for Step 2. Go back to your cPanel and to the Cron jobs section:
Before clicking on the Cron Jobs, make sure to copy or remember your cPanel Username, it is outlined at the above image at the Stats section.
Go to Add a New Cron Job, select Common Settings >> Once Per Hour:
At the Command: field type:
/usr/bin/php /home/USERNAME/public_html/wp-cron.php >/dev/null 2>&1
where USERNAME is your cPanel Username and public_html is your website's Document Root and click on Add New Cron Job:
If you have multiple WordPress websites within the cPanel account, we recommend setting up the Cron jobs to run sequentially for every other website:
Each cron will run once an hour, where the first would be at 00:05 o'clock, the second 00:10 o'clock, the third 00:15 o'clock and the fourth: 00:20 o'clock.
More info about Cron jobs? Click here: How to setup a cron job in cPanel
Should you have any further questions or need our assistance in disabling the wp-cron?
Feel free to contact us via the Open Ticket section within your MyKualo client area.
Powered by WHMCompleteSolution