WP-Cron and Background Tasks

Move non-interactive work out of visitor requests without creating unbounded or invisible background processing.

2 min read

  • Article
  • Intermediate
  • 2 minutes read
  • Reviewed August 4, 2026
  • Advanced WordPress and integrations

WP-Cron schedules events inside WordPress.

It is suitable for maintenance, publication, email, synchronization and bounded background work, but it is not a continuously running worker.

Event Model

An event combines:

  • Hook name.
  • timestamp.
  • optional recurrence.
  • arguments.
  • callback registered to the hook.

Schedule events during activation, configuration changes or another bounded lifecycle event.

Do not schedule the same recurring event on every page request without checking whether it already exists.

Default Triggering

WordPress normally checks for due events when requests reach the site.

Low-traffic sites can run jobs late. High-traffic sites can generate frequent spawn attempts.

A system scheduler can invoke WordPress cron at a controlled interval after request-driven spawning is disabled and tested.

Background Task Design

Reliable tasks should be:

  • Idempotent where possible.
  • bounded.
  • resumable.
  • observable.
  • safe to retry.
  • protected against overlap.
  • explicit about failure.

Split large imports and exports into batches.

Queues

Ecommerce and integration plugins often use queue libraries built on WordPress storage and cron.

Review queue growth, retries, dead jobs, database tables and worker capacity.

Locks and Concurrency

Prevent two workers from processing the same logical item simultaneously.

Locks also need timeouts and cleanup so a crashed process does not block work forever.

Unscheduling

Remove future events when the feature is disabled or the plugin is uninstalled, according to the data-retention policy.

Use the same arguments that were used to schedule the event.

Frequently Asked Questions

Is WP-Cron precise to the second?

No. Execution depends on triggering and available resources.

Should long work run inside a frontend request?

Not when the visitor does not need the result immediately. Use a bounded background process.

Continue Learning

Previous: Application Passwords

Next: WP-CLI