How to Disable WP-Cron for Faster Performance

disable wp cron job

WordPress uses CRON jobs to handle tasks like posting scheduled content, checking for updates, and creating backups. These tasks run through a file called wp-cron.php. WordPress runs this file every time someone visits your site. On busy websites, this can slow down page load times.

To speed up your site, it’s better to turn off wp-cron.php and use a real system cron job. This reduces server load and improves overall performance. It also makes your site more secure by lowering the risk of attacks on the wp-cron.php file. In this guide, we’ll show you how to disable WP-Cron the right way. 

What is the WP-Cron File

In WordPress, the wp-cron.php file helps run scheduled tasks automatically. WordPress triggers wp-cron.php whenever someone visits your site instead of running tasks at fixed times. It then checks if any tasks are due and runs them. Some common tasks handled by this file include publishing posts at a set time, checking for updates, and deleting old comments. 

Why the WP-Cron File Can Cause Performance Problems

If you run a high-traffic website, you might have noticed some performance hiccups with WordPress’s built-in task manager, WP-Cron. It’s important to understand that WP-Cron isn’t a true system cron; it just mimics one to handle scheduled tasks.

By default, wp-cron.php kicks in every time someone visits your site. On busy sites, this can really strain the server, especially if there aren’t enough PHP workers to go around. This can lead to delays in executing scheduled tasks. Conversely, on sites with low traffic, tasks might not run on time since there aren’t any visitors to trigger them.

WP-Cron takes care of important actions like publishing scheduled posts, checking for updates, and managing plugin notifications. As the number of tasks increases, especially on content-rich sites, the server load can rise, which may slow down website.

To boost performance, it’s often a good idea to disable WP-Cron and set up a system-level cron job instead. A system cron runs tasks on a set schedule, no matter how many users are visiting, ensuring that everything gets done reliably and on time.

How to Disable Default WP-Cron

Disabling the default WP-Cron can help improve the performance of your WordPress website. It does this by stopping the cron system from running every time someone loads a page. To do this, open your WordPress site’s root directory, locate and open the wp-config.php file, scroll down, and add the following line just above the line that says: “That’s all, stop editing!”:

define('DISABLE_WP_CRON', true);
disable wp cron

You can enable it at any time when needed. To do this, add the following line to the wp-config.php file:

define('DISABLE_WP_CRON', false);

WordPress will no longer run the `wp-cron.php` file automatically every time someone visits your site. Since we have turned off the default WP-Cron, you will need to set up another way, like a manual cron job or a plugin, to keep your scheduled tasks working properly.

Manually Schedule Cron Jobs Instead of WP-Cron

We do not want to completely turn off WordPress’s ability to run automatic tasks. However, by stopping it from running on every single visit, we get better control over when these tasks happen. For most users, setting the wp-cron.php script to run every 6 hours is enough. That means it will run only 4 times a day instead of hundreds or thousands of times when your site gets a lot of visitors.

Log in to your cPanel account and open the Cron Jobs section, located under the Advanced tab:

open cron jobs cpanel

Now, expand the Common Settings drop-down and select the “Once Per Hour” option from it:

set common settings to once per hour

Next, expand the Every Hour drop-down and select the “Every Sixth Hour” option:

every sixth hour

Finally, enter the following command to trigger the cron job, then click on Add New Cron Job:

cd ~/public_html; php -q wp-cron.php

This command allows you to run WordPress’s cron file (wp-cron.php) directly from your hosting server using an actual cron job:

add new cron job

If everything goes fine, you will be notified with the following message:

wp cron job added

Your WordPress site will now automatically handle scheduled tasks with the wp-cron.php script at specific intervals. This way, a real cron job instead of the default wp-cron gives you better performance, more reliable task scheduling, and reduces the chances of overloading your server. Moreover, you can also use free WordPress plugins instead of the control panel to create or modify cron jobs easily.

Advantages and Disadvantages of WP-Cron File

The wp-cron.php file offers some advantages as well as some disadvantages. Let’s look at its benefits and drawbacks to see if it suits your needs:

Advantages

Here are some well-known advantages of using the wp-cron.php file:

  • You do not require root or server-level access to use wp-cron.php, which is helpful for users on shared hosting or those without technical skills.
  • WordPress offers numerous plugins that make it simple to view, create, or modify cron jobs without touching code.
  • Since it only runs when someone visits your site, it is efficient for blogs or small business websites that do not get a lot of daily traffic.
  • The wp-cron.php file is built into WordPress by default, so you don’t need to manually set up any server-side cron jobs to start using it.

Disadvantages

The wp-crop file has some disadvantages as well, such as delayed task execution on low-traffic sites, too many runs on busy sites, etc. Let’s go through the following disadvantages in more detail to understand where it may fall short:

  • If your website does not get frequent visits, scheduled tasks might not run on time, or at all.
  • On busy websites, the file may run many times, which can use too much server power and make your site slower.
  • Since tasks only run during visits, it is not a good option for jobs that must happen at exact times (like sending emails or syncing data at midnight).
  • If there is an error or conflict, wp-cron.php might stop running tasks without clear warnings unless you are monitoring it.
  • Without logging tools or plugins, it is hard to know if a cron task ran successfully or failed.

Conclusion

Disabling the default cron system (wp-cron.php) of WordPress can speed up your website. It reduces the load on your server, especially if your site gets a lot of traffic. Normally, WordPress runs the wp-cron.php file every time someone visits your site. This can lead to performance issues because it may run too often on busy sites or not at all on sites with very little traffic.

By disabling the default wp-cron and setting up a real system cron job, you can control exactly when these background tasks run. It makes sure your scheduled tasks, like posting updates, sending emails, or checking for updates, run more consistently. For example, you can set the cron job to run every 6 hours, which is usually enough for most websites. You can do this using your hosting panels like cPanel, and many free plugins make it easy to schedule cron jobs without much technical knowledge.

We hope this article has helped you disable WP-cron. Consider Ultahost’s fast, user-friendly, and secure WordPress hosting to improve the security of your website. Ultahost provides features like enhanced protection against unauthorized access and unlimited bandwidth. All these features are optimized for superior website performance.

FAQ

What is WP-Cron in WordPress?
Why should I disable WP Cron?
What happens if I disable WordPress cron?
Will disabling WP-Cron stop scheduled posts or email notifications?
How do I disable WP-Cron in WordPress?
How do I run WP-Cron manually using a real cron job?
Can I use a plugin instead of cPanel to manage cron jobs?

Related Post

How to Install Tutor LMS in WordPress

Tutor LMS is a Learning Management System plugin in Wor...

How to Delete MySQL Database & User from

Deleting a MySQL database and user from cPanel is impor...

How to Fix “Serve Static Content From a Coo

Have you encountered the "Serve Static Content From a C...

wordpress google storage

How to Offload Your Media on Google Cloud Sto

Managing hundreds of thousands of media files in WordPr...

How to Block UserAgents in .htaccess file

Controlling access to your website becomes essential fo...

How to Add Code to WordPress Header and Foote

The header is the top section of a webpage. It typicall...

Leave a Comment