A guide to disable WP-Cron

Updated on February 20, 2024

What is wp-cron?

WP-Cron carries out specific duties for WordPress-powered websites. Cron is derived from the Unix system for scheduling jobs at intervals ranging from once a minute to once a year. Any command running on Unix without human involvement may be scheduled as a Cron task, whether normal maintenance or scheduled notifications.

This would be fine for low-traffic sites, but as your site visitors increase, checking for scheduled activities many times might be inefficient and cause resource consumption issues for the server, making your website run slower.

WordPress uses a file named wp-cron.php as a virtual cron job, or scheduled activity, to automate tasks such as:

  • Publish scheduled posts
  • Check for theme and plugin updates
  • Email Notifications
  • Website backups
  • Auto WordPress Updates

How does it work?

It’s designed to mimic a system cron job, which is a time-based job scheduler in Unix-like operating systems.

Here’s how WP-Cron works and can affect performance:

  1. Triggering: When a user visits a WordPress site, WP-Cron checks if there are any scheduled tasks that need to be executed. If there are tasks scheduled, WP-Cron triggers them to run.

  2. Execution: WP-Cron executes the scheduled tasks one by one. These tasks can include things like publishing scheduled posts, checking for updates, running backups, etc.

  3. Impact on Performance:

    a. Resource Usage: Since WP-Cron runs on each page load, it can consume server resources, especially on sites with heavy traffic. If there are many scheduled tasks or tasks that require significant processing power, it can slow down page load times and impact overall site performance.

    b. Inefficiency: WP-Cron’s reliance on page loads means that scheduled tasks might not always run at precisely the scheduled time, especially on low-traffic sites or during periods of inactivity. This can lead to delays in task execution.

    c. Dependency on Visitor Traffic: WP-Cron depends on visitor traffic to trigger scheduled tasks. If the site doesn’t receive regular traffic, scheduled tasks might not run as expected.

    d. Solution for High-Traffic Sites: For high-traffic sites or sites with critical scheduled tasks, it’s recommended to disable WP-Cron and set up a server-side cron job instead. This ensures that tasks are executed independently of visitor traffic, reducing the impact on performance.

Benefits of using an External Cron Job

You may be considering alternatives to the WordPress Cron Job.

Since many websites would not get visitors every second, there must be another solution.

External Cron Jobs are the solution.

  • You have more control over when it runs. You have complete control over the minute, hour, day, and so on.
  • It is simpler to write code and oversee its operation. It removes the task’s looping and timing logic, and you can adjust the timing or turn it off via crontab.
  • When it’s not running, it doesn’t take up any RAM of your system.
  • If it fails and exits for any reason, it will restart when the appropriate time comes.

How to disable WP-Cron?

It is quite simple to disable the WP-Cron by following the steps below.

  1. Connect your Server via SSH
  1. Locate wp-config.php File
  • After connecting the server, go to the webroot of your web application.
  • Go to: cd applications/application_folder_name/public_html
  • Open wp-config.php file and just before /* That’s all, stop editing! Happy publishing. */ edit the below rule:
define('DISABLE_WP_CRON', true);

Note: This prevents it from running when the page loads, rather than calling it directly via wp-cron.php.

Need More Help!

Type in your question at the knowledge base website or comment below

Leave a Comment

Your email address will not be published. Required fields are marked *