A cron job is a script or function which is executed at a scheduled time, periodically. It can be once-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 great for low to medium traffic sites, but 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. It 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 arise with the two extremes.
High traffic — If the site gets too much traffic, it is continuously checking it’s WP-CRON schedule, increasing the work required by the server, and negatively impacting performance.
Low traffic — Conversely, if there is little to no traffic, the site does not check it’s scheduled items quickly enough and may miss scheduled jobs, like a backup from a plugin or a scheduled post.
Streamlining this function is a two-part process:
- Creating a standard cron which will run any scheduled events on your site.
- Stopping WP-CRON from constantly checking for those same scheduled events.
Create 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 15 minutes.
Replace https://example.com with your domain name.
Prevent WordPress from checking for scheduled events on every page load
Follow the instructions below to disable the WP-CRON service.
- Connect to your server via WebFTP.
- Right-click the wp-config.php file and select edit.
- 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.