How to set up cronjob for WP Cron

About WP Cron

WordPress Cron (WP Cron, wp-cron.php) is the internal task scheduler in the WordPress website. It is used to run WordPress scheduled tasks. Many WP plugins are relying on WP Cron to run their backend functions.

By default WP Cron is triggered by website visits: every time a visitor loads your website, there is a small chance that your WP Cron is triggered, and it'll execute on schedule. This may not be good for you:

- The website load speed will be decreased, as it must execute backend functions.

- It eats up your server resources e.g. CPU cycles, memory, etc, as it needs to check the scheduled task list every time it's triggered.

- It's not stable, as it depends on website visits. If there are no visits for some time, the backend tasks will not be executed.

- It's not on time. If you want some functions to execute at an exact time, you'd better use a decent cronjob service like SetCronJob.

To set up cronjobs for WP Cron, follow these instructions:

Disabling WP-Cron

  1. Open your wp-config.php file with a file manager (e.g. cPanel file manager)
  2. Go to the bottom of the database settings in wp-config.php typically around line 37.

    Add the code below:

    define('DISABLE_WP_CRON', 'true');
  3. Click Save

 Set up cronjob at SetCronJob

  1. Log in to your SetCronJob account
  2. Click Add a cronjob 
  3. Enter the URL to call: (replace with your actual WordPress homepage URL)
  4. Select When to call: Every 5 minutes
  5. Click Save changes

and you're done!

If you have some plugin(s) that needs to update frequently, just change the time interval to Every minute.

You may notice that I added ?__random__ into the cronjob URL. It'll add a random number every time your cronjob is executed, so it'll prevent your web server from caching the HTTP request. 


Please sign in to leave a comment.