What is Cron?

Cron is used to schedule commands or scripts to automatically run at specified times. These tasks, or cron jobs, can be set on either a one-time or recurring basis.

WordPress comes with its own cron system which allows it to perform scheduled tasks. For example, checking for updates, send scheduled emails, publish scheduled posts, cleanup data, make backups, delete old comments from trash, etc.

However, scheduled events may fail to run if a WP website has low traffic. Some managed WordPress hosting providers, such as WP Engine, offer an alternate cron utility that works better than wp-cron.

The WP Engine alternate cron is a true cron that runs every minute on the minute, checking for and activating scheduled events. This is not enabled on your server by default, so you will have to request to have it enabled via Support. Once it has been enabled, it will ensure that the events are run as scheduled.

WP Engine Support Link: https://wpengine.com/support/

If your hosting provider does not offer an alternate cron for your WP website, you can disable the standard WP cron and replace it with a cron job running on your web hosting control panel, e.g. cPanel and Plesk. Aside from being more reliable, this helps improve your WP website’s performance and protect it from DoS attacks.

NOTE: This article assumes that your hosting provider uses cPanel. If you are using another control panel, contact your hosting provider’s support team about a suitable cron utility you can use for your website.

How to replace WP Cron with a cPanel Cron Job

  1. To begin, you need to disable WP Cron from running each time someone visits your site. To do this, open your wp-config.php file in your main WordPress folder and add the below code at the end;
     define('DISABLE_WP_CRON', true);

  2. Log in to cPanel.

  3. In the Advanced section, click Cron jobs.

  4. Locate Add New Cron Job. The cPanel Cron jobs tool has a number of common schedules preset. To execute the command every every 30 mins, select Twice an hour from the Setting drop down, we recommend setting the Cron Job every 5 minutes if your hosting company allows it.

  5. Add the following command. Replace https://www.example.com with your site’s domain;
     wget -q -O – https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

  6. Click Add New Cron Job to set the cron.

Did this answer your question?