A deep dive into how the Laravel Scheduler works internally, tracing a scheduled task from definition to execution. Covers how fluent methods like dailyAt() and weekdays() build cron expressions, how Event and CallbackEvent objects are created, and how the scheduler evaluates due events. Explains the critical difference between onOneServer() (a scheduling mutex preventing duplicate runs across servers) and withoutOverlapping() (an execution mutex preventing concurrent runs on one server). Details how background commands work via Symfony Process and schedule:finish cleanup, why closures cannot run in the background, how sub-minute scheduling keeps the process alive for a full minute using a sleep loop, and includes a practical production checklist covering idempotency, UTC usage, shared cache requirements, output capture, and observability via scheduler lifecycle events.

14m read timeFrom wendelladriel.com
Post cover image
Table of contents
IntroductionThe Scheduler Is Not CronThe Big PictureFrom Fluent Methods to Event ObjectsFrequency Methods Build a Cron ExpressionHow Laravel Finds and Filters Due EventsTwo Locks, Two Different ProblemsForeground Commands, Background Commands, and CallbacksOutput, Hooks, Context, and EventsHow Sub-Minute Schedules WorkA Practical Production ChecklistConclusion
16.7K Impressions