How to enable a CRON for WordPress

About CRONs and WordPress

WordPress does not have the traditional concept of a CRON. Instead, when any page is loaded, a the CRON routine is invoked to see if scheduled tasks must be triggered.

This can negatively affect the performance of a busy site, but can also be an issue for a site that doesn’t get hits that frequently. You might also follow this routine if you want to granular control of CRONs running. What you can do instead is disable this functionality and instead use a normal CRON. To do so:

How to Enable CRON in WordPress

First disable the built-in functionality by editing wp-config.php and adding the following:

define('DISABLE_WP_CRON', true);

Next use your control panel or the command line to add a CRON entry, for example:

*/30 * * * *  cd /home/domain/public_html; /usr/local/bin/php -q wp-cron.php

If you are using Virtualmin and CentOS 7 and you need a specific version of PHP to run the CRON, do something like the following:

*/30 * * * * cd /home/domain/public_html; /opt/rh/rh-php72/root/usr/bin/php -q wp-cron.php

Reference:
https://www.a2hosting.in/kb/installable-applications/optimization-and-configuration/wordpress2/configuring-a-cron-job-for-wordpress

Share this article

Leave a Reply

Your email address will not be published.

Scroll to Top