Disabling WP-CRON to Improve Overall Site Performance

 

Overview

These instructions explain how to streamline cron jobs on your WordPress site using a two-part process.

Background

A cron job is a script or function that is periodically executed at a scheduled time. It can include off-off tasks such as publishing a post or recurring tasks like checking for updates. To help improve performance, WordPress only checks for scheduled items with each page load, which is ideal for low to medium-traffic sites. However, on particularly busy sites, this constant scanning action can actually slow things down quite considerably.

Understanding how WP-CRON works

WP-CRON does not work the same way as a normal cron job. WP-CRON instead checks for scheduled events each time a site page is loaded. This works just fine with a steady stream of moderate traffic, but issues can arise if the traffic is too high or too low:

  • High traffic — If the site gets too much traffic, it continuously checks its WP-CRON schedule. This increases the work required by the server, which negatively impacts performance.
  • Low traffic — Conversely, if there is little to no traffic, the site does not check its scheduled items quickly enough and may miss scheduled jobs, such as a backup from a plugin or a scheduled post.

How to streamline a cron job

Streamlining a cron job is a two-part process, which includes creating a new cron job and disabling WP-CRON.

Part 1 — Creating a cron job in your DreamHost Panel

If your site is hosted on a DreamPress plan, this is already configured for you. Your server is configured to check for scheduled events every 2 minutes.

  1. Navigate to the Cron Jobs page.
  2. Create a new a new cron job.
  3. Enter the following under Command to run (make sure to replace https://example.com with your domain name):
wget -q -O - https://example.com/wp-cron.php?doing_wp_cron

Part 2 — Preventing WordPress from checking for scheduled events on every page load

To disable the WP-CRON service:

  1. Connect to your server via WebFTP.
  2. Right-click the wp-config.php file and select edit.
  3. Just before the /* That’s all, stop editing! Happy blogging. */ line, insert the following code:
    define('DISABLE_WP_CRON', true) ;

This prevents WP-CRON from executing on page load but not when called directly.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?