BlogHow-toSchedules

How to set up a real cron job for WordPress, so scheduled tasks run on time

WP-Cron only runs on page visits. How to replace it with a server cron job in cPanel, hPanel, Plesk or CloudPanel, and how to test that it works.

3 min readPerforks

A crontab line that calls wp-cron.php every 15 minutes

Scheduled posts that publish late, emails that go out hours later, backups that start in the morning instead of at 03:00: they usually have the same cause. WordPress has no clock of its own. This guide replaces its built-in scheduler with a real one on the server. It takes five minutes and helps every scheduled task on the site, not only backups.

How WP-Cron really works

WP-Cron is not a service that runs in the background. On each page visit, WordPress checks whether any task is due and, if one is, starts it. No visit means no check. That causes trouble in three situations:

  • A quiet site. Nothing happens until someone comes along.
  • A site behind a page cache or a CDN. Visits answered from the cache may never reach PHP, so even a busy site can behave like an empty one.
  • A very busy site. Checking on every visit is wasted work.

A real cron job fixes all three: the server calls wp-cron.php at fixed times, visitors or not.

The command

This is the line, with your own address. It asks for wp-cron.php every 15 minutes and throws the answer away:

*/15 * * * * curl -s https://example.com/wp-cron.php > /dev/null

Where curl is not available, wget does the same, as in the WordPress documentation:

*/15 * * * * wget --delete-after https://example.com/wp-cron.php

In a hosting panel you enter only the part after the five time fields, and choose the timing from a form. Every 15 minutes is a sensible start. If a site has tasks that need many steps, every 5 minutes is better, if the host allows it.

Where to add it

PanelWhere
cPanelAdvanced › Cron Jobs, then Add New Cron Job
Hostinger hPanelAdvanced › Cron Jobs, with a custom command
PleskScheduled Tasks of the domain, as a task that fetches a URL
CloudPanelThe site's Cron Jobs tab
A server of your owncrontab -e

Menus change between versions, and managed WordPress hosts often have their own scheduler or run WP-Cron from the server already. Look in your host's documentation before adding a second one.

Turn off the check on page visits

Once the job runs, stop WordPress from also checking on every visit. Add this line to wp-config.php, above “That's all, stop editing!”:

define( 'DISABLE_WP_CRON', true );

Do this only after the cron job is in place. With this line and no job, no scheduled task runs at all. Keep a backup of wp-config.php before you edit it.

Test that it works

  1. Open https://example.com/wp-cron.php in a browser. A blank page is the correct answer. An error page or a login screen means something blocks it, and the cron job will hit the same wall.
  2. From the terminal, if you have one, run wp cron event list: nothing should be overdue by more than your interval.
  3. Open Tools › Site Health, which warns about scheduled events that are late.
  4. With Restora, the line under the schedule says when the next backup is due, and after that time the screen shows “Last scheduled backup: completed on …”.

If it does not run

  • A firewall or bot protection blocks the request. A security plugin or a CDN rule may refuse wp-cron.php. Allow requests from the server's own address.
  • The address redirects. Use the exact address of the site: with or without www, and with https.
  • HTTP authentication protects the site. The job has to send the username and password, or run wp-cron.php with PHP from the command line. Hosts document the PHP path for this.
  • The host limits how often jobs can run. Some cheap plans do. Choose the shortest interval the plan allows.

Why this matters for backups

A scheduled Restora backup starts through WP-Cron, and it then keeps itself going with requests to the site's own address. Where a site cannot call itself, each following step waits for the next cron run, so the job's interval sets the pace: that is when every 5 minutes pays off. If the job stops working, Restora tells you in Site Health and by email; see scheduled backup did not run.