Are you unsure what is WP-Cron, if your site need it, and/or how to disable it?
Do you want to remove wp-cron and replace it with a genuine cron job?
In high-traffic sites, replacing wp-cron with your own cron job can help you perform your site’s scheduled activities more reliably while simultaneously reducing the burden on your server.
What is WP-Cron?
WP-Cron is a file/feature that manages the time-sensitive tasks on your WordPress website.
Let’s imagine you’ve scheduled a post to go live at 9:30 a.m. on Wednesday. Wp-cron ensures that this occurs on time (or as near to “on time” as feasible – more on that in a moment).
Many WordPress plugins rely on wp-cron to manage schedule-sensitive elements of the plugin in addition to ensuring that basic WordPress functionality work.
Why would you want to disable WP-Cron?
Disabling wp-cron and replacing it with your own dedicated cron job is for two reasons:
- Reliability: Because it requires a website visit to run, wp-cron isn’t always dependable on low-traffic sites, as the example above shows. With a genuine cron job, you may schedule your tasks to run every X minutes, regardless of whether or not there are any visitors.
- Performance — some users dislike wp-cron on high-traffic sites since WordPress runs the wp-cron.php file on practically every visit. WordPress attempts to keep this to a minimum by not executing it more than once every 60 seconds, but there can still be performance issues due to a variety of technical factors, such as several visitors activating wp-cron at the same time.
How does WP-Cron Work?
WP-Cron can only work if people visit your site, which is one of its biggest flaws.
Every time you or someone else visits your WordPress site, WordPress runs wp-cron.php and checks to see if any tasks have been set up. If there are tasks that have been set to run, WordPress will then do them and finish them.
How to Disable WP-Cron?
Let’s dive into the “how” now that we’ve covered the “what” and “why.” wp-cron will be disabled, and your own server cron job will be installed in its stead (or another solution).
In order to complete the procedure, there are two steps:
- In order for WordPress to not execute the built-in wp-cron function on every visit, you must disable the wp-cron feature. A single line of code in your site’s wp-config.php file is all that’s required.
- In order to have wp-cron.php run at the times you specify, you must create a cron job to do so. WP-cron.php may be executed on a predetermined schedule, regardless of whether or not your site receives visitors.
Conclusion
WP-Cron is a WordPress plugin that helps you manage time-based activities on your site. However, for low-traffic sites, the default method it operates can be unstable, and for high-traffic sites, it might create performance concerns.
For these reasons, you should disable the default system and replace it with your own time-based cron system.