Skip to main content

How to set-up a cron job in WordPress

If your website doesn't have a lot of visitors yet, the WordPress cron job will not be triggered and background processes will not be executed.

Jessica Risch avatar
Written by Jessica Risch
Updated over a week ago

What is a cron job?

A cron job pings your website to trigger the execution of tasks. For example a stock or price update. It's critical that the cron job is getting triggered, otherwise your website will be out of sync or delayed in updates.

Set-up a cron job on your server

In some occasions it's recommended to set-up a cron job outside of WordPress, to be sure that background processes run on time. Issues that can be caused due to cron jobs not being executed:

  • Updating products is stuck or slower than expected (every 30 minutes should be the standard)

  • Product import is stuck or very slow

  • Scheduled Actions with status pending state are piling up

The WordPress cron system relies on website visitors. If your website doesn't have regular visits yet, the background processes don't run often or fast enough. To prevent this from happening, it's recommended to set-up a cron job which will access the website as if it's a visitor and triggers the background processes.

We recommend to set-up a cron job that visits the site every 3 minutes using the following permalink as example:

Follow the steps below to configure the cron job on your server:

Step 1) Disable the default WordPress cron

Add this to your wp-config.php file:

define('DISABLE_WP_CRON', true);

This prevents WordPress from triggering cron on page loads.

Step 2) Add a real cron job

Execute the following steps on a normal Linux server:

  • Open terminal (SSH into server)

ssh user@yourserver
  • Open crontab

crontab -e
  • Add this line

*/5 * * * * /usr/bin/php /home/username/public_html/wp-cron.php > /dev/null 2>&1

Cron timing explained

*/5 * * * *

This means:

  • Every 5 minutes

  • Every hour

  • Every day

  • Every month

  • Every weekday

For WooCommerce:

  • Every 5 minutes = ideal

  • Every 1 minute = heavy stores

  • Every 15 minutes = low traffic blog

One click cron job integration Woosa plugin

All Woosa plugins support a feature called Heartbeat. This is an external cron job set-up on the Woosa servers, which can be enabled in the plugin settings of all our plugins with one simple click.

Follow the steps below to enable the Woosa heartbeat/cron job:

  • Go to your WordPress backend

  • Click on the Woosa plugin name (e.g. vidaXL) in the WordPress menu

  • Go to the Heartbeat tab

  • Click to enable the Heartbeat

NOTE: it can happen that your server is blocking visits from our heartbeat/cron job URL, due to IP restrictions or firewalls. If that's the case, please consult our support desk. They will assist you in solving this issue.

Did this answer your question?