Skip to content

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 rely 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 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 reliable cronjob service like FastCron.

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

Disable WP-Cron

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

Add the code below:

define('DISABLE_WP_CRON', true);

then save the file.

Set up cronjob at FastCron

  • Log in to your FastCron account
  • Click Add a cronjob
  • Enter the URL to call

(replace with your actual WordPress homepage URL)

  • Select When to call: Every 5 minutes
  • Click Save changes.

And you’re done!

If you have some plugins that needs to update frequently, just change the time interval to Every minute.

You may notice that I add ?__random__ to the cronjob URL. It’ll add a random string every time your cronjob is executed, preventing your web server from caching the HTTP request.

Some WordPress plugins rely on WP Cron to run their scheduled tasks. If you’re using one of these, set up a cronjob to run your website WP cron.