The cron tick
cron.php boots the application, dispatches a single event, and flushes:
What runs on each tick
Plugins subscribe to the same event. See Events and cron.
Batching and cursors
A tick may arrive every minute, so listeners process a bounded batch and remember where they stopped. Renewal, for example, handles a limited number of workspaces per run and stores its position in an option such asoption.cron.renew_subscriptions.cursor_id.
That pattern is worth copying:
Process a fixed number of records per run.
Persist a cursor, so the next run continues.
Keep a status, so an administrator can start, pause and stop the work.
Return early when there’s nothing to do, so an idle installation costs nothing.
Import jobs
Imports are the closest thing to a queue: an upload creates a job record, and each tick advances it through the adapter in batches, tracking progress and skipping duplicates. The job carries its own status and counters, so the interface can show progress. See Import adapters.Provider webhooks
Some work isn’t scheduled at all: it finishes when a third party says so. Video and image generation at several providers is asynchronous, and the provider calls a dedicated endpoint when the result is ready. Payment providers do the same for cancellations and asynchronous settlements.
See Payment webhooks.
Timing and reliability
- Entity changes are flushed after the cron event finishes, the same as in a web request.
- There’s no retry. A listener that throws stops that listener; the next tick starts fresh. Catch your own exceptions and record failures.
- Ticks can overlap if one run takes longer than the interval. Keep batches small enough to finish well inside a minute.
- Nothing is guaranteed to run on time. Some hosts limit cron to every 15 minutes, which delays renewals accordingly.