WordPress uses a built-in scheduling system called wp-cron to handle time-sensitive tasks like publishing scheduled posts, checking for updates, and sending emails.
However, wp-cron is triggered by site visits, which can lead to performance issues on high-traffic sites or missed tasks on low-traffic sites.
Disabling wp-cron and using a server-level cron job can improve reliability and performance.
Steps to Disable wp-cron
1. Access your wp-config.php file:
- Use an FTP client or cPanel's file manager to navigate to the root directory of your WordPress installation.
- Locate the wp-config.php file.
2. Edit the wp-config.php file:
- Download the wp-config.php file to your computer and open it in a text editor.
- Add the following line of code just before the line that says, "That's all, stop editing! Happy blogging":
define('DISABLE_WP_CRON', true);
3. Save the changes and upload the file back to your server.
Setting Up a Proper Cron Job
After disabling wp-cron, you need to set up a server-level cron job to handle scheduled tasks.
1. Log in to your cPanel (EG. http://yourdomain.com/cpanel)
2. In the "Advanced" section, click Cron Jobs icon
3. In the "Add New Cron Job" section:
Common Settings: [Set the desired frequency (e.g., every 15 minutes)]
Command: /usr/bin/php /home/username/public_html/wp-cron.php
* Replace username with your actual hosting username
4. Click Add New Cron Job to save the changes.