Table Of Contents
Introduction
If you’ve ever noticed slow page loads or inconsistent scheduled tasks on your WordPress site, WP-Cron might be the silent culprit behind the scenes. WP-Cron is WordPress’s built-in task scheduler, responsible for running time-based tasks like publishing scheduled posts, checking for updates, and sending emails. While it works for many small to mid-size websites, it has its limitations.
Every time someone visits your website, WordPress checks if any scheduled tasks need to run. This means WP-Cron doesn’t operate like a traditional server cron job – it’s visitor-dependent. So, if your site has low traffic, tasks might not run on time. And on high-traffic websites, WP-Cron can run too frequently, affecting performance.
Disabling WP-Cron and setting up a real cron job is a common solution for improving site stability and speed. In this article, we’ll explore why and how to disable WP-Cron safely and replace it with a server-level cron job to ensure scheduled tasks run consistently.
Whether you run a WooCommerce store or a personal blog, understanding and optimizing cron behavior can significantly improve your site’s efficiency.
What Is WP-Cron and Why Should You Disable It?
WP-Cron (wp-cron.php) is not a real cron job. Instead of running tasks at set intervals, it triggers on every page load. Here’s what that means:
Why It Can Be a Problem:
- Performance Bottlenecks: On high-traffic sites, wp-cron.php may run multiple times within seconds, creating a server strain.
- Missed Tasks: On low-traffic sites, tasks may not run at all if there’s no visitor at the scheduled time.
- Random Failures: Shared hosting environments often block or delay WP-Cron execution, especially under heavy load.
Common Issues Caused:
- Scheduled posts not publishing
- Backups failing
- Email notifications not sent
- Plugin updates getting stuck
By disabling WP-Cron and replacing it with a system-level cron job, you get more reliability and better server performance.
How to Disable WP-Cron in WordPress
Disabling WP-Cron is straightforward and involves editing the wp-config.php file.
Step-by-Step Instructions:
- Access Your Website Files: Use your hosting file manager or connect via FTP/SFTP using tools like FileZilla.
- Open wp-config.php: This file is in your site’s root directory (where you see wp-content, wp-includes, etc.).
- Add the Disable Command: Insert the following line above the line that says /* That’s all, stop editing! Happy blogging. */:
define(‘DISABLE_WP_CRON’, true); - Save and Exit
That’s it – WP-Cron is now disabled. But remember, you still need to set up a real cron job to handle scheduled tasks.
How to Set Up a Real Cron Job to Replace WP-Cron
After disabling WP-Cron, your scheduled tasks won’t run unless triggered manually or through a server cron job.
Setting It Up via cPanel (Most Common Hosting)
- Login to cPanel: Navigate to your hosting account’s control panel.
- Find “Cron Jobs” Section
- Add a New Cron Job
- Recommended Frequency: Every 5 minutes
- Command to Run:
wget -q -O – https://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 - Replace yourwebsite.com with your actual domain.
- Save
This setup triggers wp-cron.php at fixed intervals, regardless of site traffic.
Alternative Commands for Cron Job:
If wget is not available, you can use:
curl https://yourwebsite.com/wp-cron.php?doing_wp_cron
Or using PHP CLI (on VPS/Dedicated):
php /home/username/public_html/wp-cron.php
Common Use Cases: When Should You Disable WP-Cron?
Not every WordPress site needs WP-Cron disabled. But if any of the following applies to you, it’s time to make the switch:
Use Case | WP-Cron Status |
High-traffic blogs | Disable |
WooCommerce stores | Disable |
Membership websites | Disable |
Scheduled posts failing | Disable |
Low-traffic blogs | Consider it |
Small hobby websites | WP-Cron is okay |
Real-world example: A WooCommerce store with flash sales and multiple plugins started missing scheduled email reminders. After disabling WP-Cron and switching to a server cron job, task reliability increased, and server load dropped by 15%.
Best Practices After Disabling WP-Cron
- Test Task Execution: After setup, publish a scheduled post or use plugins like WP Crontrol to confirm tasks are running.
- Monitor Server Load: A well-set cron job should reduce load. If it’s increasing, check for misconfiguration.
- Backup Regularly: Especially before changing core files like wp-config.php.
- Use a Cron Job Monitor: Tools like Cronitor or Better Uptime can notify you if your scheduled tasks fail to run.
- Log WP-Cron Jobs: Use a plugin like WP Crontrol to see scheduled tasks and debug any issues.
Pros and Cons of Disabling WP-Cron
Pros | Cons |
Consistent task execution | Slightly more complex setup |
Improved site performance | Requires server access |
Avoids duplicate task execution | Cron jobs can fail if misconfigured |
Better control over frequency | Not all hosting providers allow cron jobs |
Conclusion
Disabling WP-Cron in WordPress can significantly enhance the reliability of your website’s scheduled tasks and reduce server load. While it’s not required for every site, high-traffic websites, WooCommerce stores, and membership platforms benefit the most from making the switch.
By editing your wp-config.php file and setting up a proper server-level cron job, you ensure your site functions smoothly, even under heavy load or low traffic. It’s a small tweak that can lead to big performance gains and fewer missed tasks.
FAQ Section
1. What is WP-Cron in WordPress?
WP-Cron is WordPress’s internal scheduler that runs tasks like publishing posts and sending emails whenever a visitor loads a page.
2. Why should I disable WP-Cron?
Disable WP-Cron if your site has performance issues or if scheduled tasks often fail. It’s visitor-dependent and can cause delays or overuse server resources.
3. How do I disable WP-Cron in WordPress?
Add define(‘DISABLE_WP_CRON’, true); to your wp-config.php file, just above the “stop editing” line.
4. Will disabling WP-Cron break my site?
No, but scheduled tasks won’t run unless you set up a real cron job at the server level to replace it.
5. What command should I use for a server cron job?
Use wget -q -O – https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 in your hosting control panel’s cron job section.
6. How often should I run the server cron job?
Running it every 5 or 10 minutes is typical. Adjust based on how frequently your site runs scheduled tasks.
7. Can I re-enable WP-Cron later?
Yes. Just remove or comment out the line define(‘DISABLE_WP_CRON’, true); in your wp-config.php file.
8. What plugin can help manage WP-Cron jobs?
Use WP Crontrol to view, edit, and debug cron jobs directly from your WordPress dashboard.
You May Like These Useful Tips
How to Disable Auto Excerpt in WordPress?