WordPress uses a file called wp-cron.php to run scheduled tasks such as publishing posts, checking for plugins, theme updates, and sending notifications. However, this file cannot self-execute. It only checks for scheduled tasks whenever someone visits your site.
It works fine with sites that get decent traffic, but not necessarily for sites with high and low traffic. If your site gets high traffic, tasks will pile on top of each other, consuming server resources. For sites that get low traffic, it will take time before your tasks can be executed.
By default, WordPress views the wp-cron.php and asks it for tasks. So, turning it off and forgetting about it is not recommended. You just have to disable the default file and then set up a Cron Job on the Hosting Manager to automate a command on your site.
Disable Default WP-cron.php
Follow the steps given to disable default wp-cron.php:
- Access your File Manager.
- Locate the public_html folder. Then, click wp-config.php.
- Right-click on the file, and select Code Edit.
You can also click wp-config.php, then select Code Editor button on the upper part of the page.
- A code editor popup will display, just click Edit.
- Look for the database setting in wp-config.php file. Then, add the following bolded code in the location indicated:
/** The Database Collate type. Don't change this if in doubt. */
- Click Save Changes at the upper right corner.
will no longer run wp-cron.php file whenever there is a visitor. To automate certain commands, proceed to setting up a cron job for wp-cron.php.
Set up a Manual Cron Job for WP-cron.php
After you have disabled the default wp-cron.php, you can now control wp-cron.php by setting up a manual cron job. Follow the steps below to be guided.
- Access your Hosting Manager.
- On the Home page, click Advanced or the [ v ] arrow symbol on the right side, then click Cron Jobs.
- Scroll down to Add New Cron Job.
- On the box provided for Common Settings, select Once Per Hour (0****).
- On the Common Settings under Hour, select Every Sixth Hour (*/6).
- Scroll down to Command field, and enter the following code to run the cron job:
cd /home/username/public_html; php -q wp-cron.php
(This refers to the primary domain /home/username/public_html, if your WordPress was installed in a sub directory, set this path to the correct location).
- Click Add New Cron Job.
Congratulations! Your WordPress site will now run the wp-cron.php script at the scheduled intervals. If you need any further assistance or if you have any questions in disable the wp-cron.php in WordPress, please let us know. We’d love to help!