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.

Advertisement

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.

Add a comment

Leave a Reply

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

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement