WordPress has a built-in WordPress cron task scheduler known as wp-cron. This cron scheduler can be used to perform various tasks at predetermined intervals, such as creating scheduled backup, publishing scheduled posts, checking for updates, and running plugin tasks. However, wp-cron can sometimes cause performance issues, especially on high-traffic websites but there is a way to disable wp-cron and activate external cron jobs.
In this article, we’ll go through the steps required to disabled WordPress cron and to activate external cron jobs.
Identify the Current WordPress Cron Job System
Before we can start the process of disabling wp-cron and activating external cron jobs, we need to find out which system is currently in use. There are two possibilities here:
- Linux Cron: This is a system-level task scheduler that runs on the server itself. It can be used to run tasks at specific times or intervals.
- cPanel Cron: This is a task scheduler that is built into the cPanel hosting control panel. It can be used to run tasks at specific times or intervals.
If you’re not sure which system your hosting provider uses, you can contact them and ask.
Disable wp-cron Job
Once you know which cron system is in use, the next step is to disable wp-cron. To do this, you need to add the following line of code to your wp-config.php file:
This code tells WordPress not to run wp-cron automatically. Once you’ve added this code, you’ll need to set up an external cron job to run the wp-cron.php file on a regular basis.
Set Up an External Cron Job
To set up an external cron job, you’ll need to use either Linux Cron or cPanel Cron, depending on which system your hosting provider uses. Here are the steps for each system:
- Log in to your server using SSH.
- Run the following command to open the crontab editor:
One of the critical tasks in running a website is to ensure that you have a backup of your data in case of any data loss or corruption. WP Staging is a popular plugin used to create staging environments on WordPress websites. It also provides a backup feature that allows you to schedule backups of your website data.
In this article, we will guide you on how to disable the normal WordPress wp-cron jobs and use an external cron for the backup plugin WP Staging and for all other plugins that relie on cron jobs.
- Add the following line of code to the crontab file:
*/15 * * * * /usr/bin/php /path/to/your/wordpress/installation/wp-cron.php > /dev/null 2>&1
This code tells the system to run the wp-cron.php file every 15 minutes. Make sure to replace “/path/to/your/wordpress/installation/” with the actual path to your WordPress installation.
- Save and close the crontab file.
- Log in to cPanel and go to the Cron Jobs section.
- Click on the “Add New Cron Job” button.
- In the “Command” field, add the following code:
Make sure to replace “username” with your actual cPanel username.
- Set the interval to “Every 15 minutes”.
- Click on the “Add Cron Job” button to save the changes.
That’s it! You’ve now disabled wp-cron and set up an external cron job to run the wp-cron.php file at regular intervals.
Disabling wp-cron and activating external cron jobs can help improve the performance of your WordPress website, especially if you have a lot of scheduled tasks. By following the steps outlined in this article, you can easily set up an external cron job and ensure that your scheduled tasks are running smoothly. If you have any questions or run into any issues, don’t hesitate to contact your hosting provider for assistance.