Do I need to do anything?
| How WordPress was installed | What to do |
|---|---|
| From the Apps page in your Enhance panel | Nothing – the cron job is added for you automatically. |
| Uploaded, moved from another host, or installed by hand | Add a cron job using the steps below. |
Not sure? Check your list of cron jobs (step 3 below). If you can already see one containing cron event run --due-now – starting with either wp or wp-cli – you’re all set.
Why we do this
WordPress has a built-in scheduler called WP-Cron. Instead of running on a timer, it checks for jobs every time someone visits your website. That causes problems:
| The problem with WP-Cron | What a real cron job does instead |
|---|---|
| Slows your website down. Visitors can be kept waiting while background jobs run. | Runs in the background, so your visitors never wait for it. |
| Unreliable on quieter websites. No visitors means no jobs, so scheduled posts and backups can be late or missed. | Runs on time, every time, whether or not anyone visits. |
| Wasteful on busy websites. It checks on every single page view, using resources over and over for nothing. | Checks once, at a set time. |
| Affects everyone on the server. Lots of websites doing this at once uses resources that could be making every website faster. | Spread across the hour, so the server stays fast for you and everyone else. |
So a real cron job makes your website faster and more reliable, and helps keep the server quick for every customer.
Add the WordPress cron job
- Select Websites in the left side bar, then select your website.
- In the menu along the top, open the Advanced drop-down and select Developer tools.
- Select Cron jobs in the menu on the left (or scroll down).
- Select Add cron job.
- Enter this command exactly:
wp-cli cron event run --due-now --path=public_html
- Set Interval to Custom.
- In the Minute box, enter any number from 0 to 59 – for example 23. The menu next to it changes to Custom.
- Leave the other boxes as they are, each set to *: Hour (Every hour), Day of month (Every day of the month), Month (Every month) and Weekday (Every day of the week).
- Select Save.
Your cron job will now run once an hour, at that many minutes past the hour – for example at 10:23, 11:23, 12:23 and so on.
WordPress in a subfolder or on another domain?
The command above is for WordPress in your website’s public_html folder. If it’s somewhere else, change the end of the command to match the folder, for example:
wp-cli cron event run --due-now --path=public_html/blog
Each WordPress installation needs its own cron job.
Good to know
- Once an hour suits most websites. If a plugin needs its tasks run more often, for example for a busy online shop, please contact us and we’ll advise.
- Leave “Allow editing of cron from website container” switched off. You don’t need it for this – see how to set up a cron job.
- Prefer the command line? See getting started with WP-CLI.