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 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 FastCron.
To set up cronjobs for WP Cron, follow these instructions:
- 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 typically around line 37.
Add the code below:
- Click Save
Set up cronjob at FastCron
- Log in to your FastCron account
- Click Add a cronjob
- Enter the URL to call:
http://yoursite.com/wp-cron.php?doing_wp_cron&__random__(replace http://yoursite.com/ with your actual WordPress homepage URL)
- Select When to call: Every 5 minutes
- 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 add
?__random__ to the cronjob URL. It'll add a random number every time your cronjob is executed, preventing your web server from caching the HTTP request.