Running wp-cron with cronjob

WordPress runs cronjob when a visitor visits your website, if your site is busy, cronjob checking occurs for every page request. This increases server resource usage.

To run wp-cron with cronjob we need to disable WordPress cronjob. Edit wp-config.php and add the following

define('DISABLE_WP_CRON', 'true');

Now set up a normal cronjob.

if you have wp-cli installed, use the following cronjob

*/5 * * * * cd /var/www/html; wp cron event run --due-now > /dev/null 2>&1

If you don’t have wp-cli installed, use

*/5 * * * * cd /var/www/html; php -q wp-cron.php

Replace /var/www/html to the actual folder where your WordPress installation is located.

Back to WordPress

Comments

Leave a Reply

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