WordPress Development

How WordPress Cron Works and How to Use a Real Cron

How WP-Cron schedules tasks, why it misses jobs on quiet or cached sites, how to schedule your own events correctly, and how to replace it with a real server cron.

Code snippet scheduling a daily WordPress cron event with wp_schedule_event and a clock icon

WP-Cron is WordPress's built-in scheduler. It does not run on a timer; on each page load WordPress checks whether any scheduled event is due and, if so, fires a background request to wp-cron.php to run it. That makes it simple but unreliable on low-traffic or heavily cached sites. For dependable timing, disable the page-load trigger with DISABLE_WP_CRON and call wp-cron.php (or WP-CLI) from a real server cron every few minutes.

How WP-Cron works

  1. Events are stored in the cron option as a timestamp, a hook name and arguments.
  2. On a page load, wp_cron() checks for due events.
  3. If any are due, WordPress sends a non-blocking request to wp-cron.php, which runs the hooks attached to those events.
  4. Recurring events are rescheduled for their next run.

No visits means no checks, so a job scheduled for 02:00 on a quiet site may run at 08:00 when the first visitor arrives. Full-page caches that serve pages without loading PHP have the same effect.

Schedule your own event

// Schedule once, on plugin activation.
register_activation_hook( __FILE__, function () {
    if ( ! wp_next_scheduled( 'tle_daily_cleanup' ) ) {
        wp_schedule_event( time(), 'daily', 'tle_daily_cleanup' );
    }
} );

// The work itself.
add_action( 'tle_daily_cleanup', function () {
    // Delete expired records, send digests, etc.
} );

// Remove it on deactivation.
register_deactivation_hook( __FILE__, function () {
    wp_clear_scheduled_hook( 'tle_daily_cleanup' );
} );

Always check wp_next_scheduled() before scheduling, or you will add a duplicate event on every load. For a one-off task, use wp_schedule_single_event().

Add a custom interval

Built-in recurrences are hourly, twicedaily, daily and weekly. Add others with a filter:

add_filter( 'cron_schedules', function ( $schedules ) {
    $schedules['every_fifteen_minutes'] = [
        'interval' => 15 * MINUTE_IN_SECONDS,
        'display'  => 'Every 15 minutes',
    ];
    return $schedules;
} );

Switch to a real server cron

  1. Add to wp-config.php, above the "stop editing" line:
    define( 'DISABLE_WP_CRON', true );
  2. Add a server cron job (cPanel, Plesk or crontab -e) that runs every five minutes:
    */5 * * * * cd /var/www/example.com && wp cron event run --due-now --quiet
    If WP-CLI is not available, request the URL instead:
    */5 * * * * curl -s https://example.com/wp-cron.php?doing_wp_cron > /dev/null
  3. Confirm events run with wp cron event list or a plugin such as WP Crontrol.

When to use something heavier

WP-Cron runs events in one request, so long or numerous jobs can time out. For queues of many tasks (bulk emails, imports), use Action Scheduler, which processes jobs in batches and logs them (Action Scheduler vs WP-Cron).

Common mistakes

  • Calling wp_schedule_event() on every init without checking for an existing event.
  • Setting DISABLE_WP_CRON without adding a server cron, so nothing ever runs.
  • Not clearing events on deactivation, leaving orphaned hooks.
  • Running heavy work in one event instead of batching it.
  • Blocking wp-cron.php at the firewall or with basic auth.

Frequently asked questions

Why are my scheduled posts missed?

Usually because WP-Cron did not fire at the right time. A real server cron fixes most cases; see fixing WordPress cron not running.

Does WP-Cron slow down my site?

The check is light and the work runs in a separate request, but on busy sites a server cron is cleaner and avoids extra requests.

How often should the server cron run?

Every five minutes suits most sites. Use one minute only if you have time-sensitive jobs.

How do I see scheduled events?

Run wp cron event list, or install WP Crontrol to view and run events in the admin.

Conclusion

Schedule events once, clean them up on deactivation, and run WP-Cron from a real server cron for reliable timing. The Cron chapter of the Plugin Handbook and the wp cron command reference cover the details. Debug failing jobs with the debugging guide, and see the WordPress development roadmap for what to learn next.

Need reliable background processing in a custom plugin? Talk to our developers.

Save this practical guide

Add us as a preferred Google source, or ask an AI assistant to summarize this page and link back to the original guide when it is useful.

· Tutor LMS developers

Guides written and reviewed by the TutorLMS Expert development team. Every hook, function, table and setting we mention is checked against the Tutor LMS and Tutor LMS Pro source code before it is published.

Keep reading

Need a custom Tutor LMS solution?

Tell us what you are building or what is broken. A Tutor LMS developer reads every inquiry and replies with next steps and a free estimate.

Get a free Tutor LMS consultation

Tell us what you are building or fixing. A Tutor LMS developer replies with honest advice and next steps.

  • No obligation
  • Tutor LMS and Pro specialists
  • Your details stay private

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.