Laravel Schedule Monitor
spatie/laravel-schedule-monitor is a Laravel package that keeps track of your scheduled tasks. Every time a task in your schedule starts, finishes, fails, or is skipped, the package writes a row to a log table in your database. An Artisan command shows, per task, when it last ran, whether that run failed, whether it finished late, and when it will run next. Optionally, the package syncs your schedule with Oh Dear's cron monitoring, so that an outside service notifies you when a task does not run on time or fails.
This documentation is written from the package's source code and tests (version 4.3.x) and goes well beyond the README: it covers how task names are derived, exactly when a run counts as late or failed, what each sync mode does to your data, how pings reach Oh Dear, and the quirks you should know about before relying on it in production.
The Problem It Solves
Laravel's scheduler is "fire and forget". If schedule:run stops being called by cron, if a command starts throwing exceptions, or if a nightly job slowly creeps past its window, nothing tells you. Logging inside every command is repetitive and still does not catch the case where the scheduler itself never runs.
This package hooks into the scheduler's own events, so every scheduled task is monitored without changing the task code:
- a database history of every start, finish, failure, and skip, with runtime, exit code, memory usage, and (optionally) the task's output;
- a console overview (
schedule-monitor:list) highlighting failed and late tasks; - an external watchdog through Oh Dear, which notices when the expected ping does not arrive, something a notification sent from inside your own app could never do if the scheduler is down.
Key Features
| Feature | Where to read more |
|---|---|
| Automatic monitoring of commands, shell commands, queued jobs, and closures | Naming Tasks |
Log items for each starting, finished, failed, and skipped event |
How Monitoring Works |
| Per-task options: custom name, grace time, opt out, opt out of Oh Dear only, store output | Scheduler Methods |
| Overview of all tasks with last start, finish, failure, and next run | schedule-monitor:list |
| Synchronizing the schedule with the database and Oh Dear | schedule-monitor:sync |
| Checking the Oh Dear connection | schedule-monitor:verify |
| Queued pings to Oh Dear with retries, custom job class, debug logging, failure event | Oh Dear Pings |
| Custom Eloquent models and model pruning | Database and Models |
A Short Example
Install the package, publish and run the migration, then sync the schedule:
composer require spatie/laravel-schedule-monitor
php artisan vendor:publish --provider="Spatie\ScheduleMonitor\ScheduleMonitorServiceProvider" --tag="schedule-monitor-migrations"
php artisan migrate
php artisan schedule-monitor:sync
From then on every run of a scheduled task is recorded. Most tasks need nothing extra; a few may need a name or a longer grace time:
// routes/console.php
use Illuminate\Support\Facades\Schedule;
Schedule::command('reports:send')->dailyAt('02:00')->graceTimeInMinutes(20);
Schedule::call(fn () => cache()->forget('stats'))
->hourly()
->monitorName('clear-stats-cache');
Schedule::command('telescope:prune')->daily()->doNotMonitor();
Check the state of your schedule at any time:
php artisan schedule-monitor:list
The Quick Start walks through this step by step with the output you should expect.
How It Works
schedule-monitor:syncreads your schedule, determines a name for each task, and stores one row per task in themonitored_scheduled_taskstable. If Oh Dear is configured, it also creates a cron check at Oh Dear for each task and stores the check's ping URL on the row.- When the scheduler runs a task, Laravel fires
ScheduledTaskStarting,ScheduledTaskFinished,ScheduledTaskFailed, orScheduledTaskSkipped. The package listens to these events, looks up the task's row by name, and writes a row tomonitored_scheduled_task_log_items. - If the task has a ping URL, a queued
PingOhDearJobsends the result to Oh Dear. Oh Dear compares the pings with the cron expression and grace time it received during the sync and notifies you when a run is missing, late, or failed. schedule-monitor:listcombines the schedule in your code with the timestamps in the database to show what ran, what failed, and what is overdue.
Tasks that were never synced have no row, so their events are ignored. That is why the sync must run on every deployment. See How Monitoring Works for the details.
When to Use It, and When Not
Use it when you want a history of scheduled task runs in your own database, a quick console view of the schedule's health, or reliable "dead man's switch" alerts through Oh Dear without writing any monitoring code.
Keep in mind:
- The package itself never sends notifications. Its reasoning (from the README) is that if your scheduled tasks are not running, a scheduled task that sends notifications probably is not running either. Alerts come from Oh Dear, or from a third-party service you wire up yourself.
- Tasks that use
between,unlessBetween,when, orskipare listed as unsupported by the README: their runs depend on conditions that a cron expression cannot express, so an external monitor would expect runs that never happen. See Troubleshooting. - Only tasks whose name can be determined (or that you name with
monitorName()) can be monitored.
Requirements at a Glance
| Requirement | Version |
|---|---|
| PHP | ^8.2 |
Laravel (illuminate/bus) |
11, 12, or 13 |
| Database | Any database supported by Laravel migrations, including a json column |
| Oh Dear (optional) | An Oh Dear account, an API token, and a monitor id |
Laravel 8 users can install version 2 of the package. See Installation for details.
Project Status
The package is maintained by Spatie and actively released: the 4.x line accepts Laravel 11 to 13 in composer.json, and CI currently tests Laravel 12 and 13 on PHP 8.2 to 8.6. See the changelog for release notes and the upgrade guide when moving between major versions. It is released under the MIT license.
Alternatives to Oh Dear
The package integrates with Oh Dear only, but its README lists other services that can watch scheduled tasks if you prefer to ping them yourself: thenping.me, Healthchecks.io, Cronitor, Cronhub, DeadMansSnitch, CronAlarm, and PushMon.
Where to Go Next
- Installation: install the package, create the tables, publish the configuration.
- Quick Start: monitor your first tasks in five minutes.
- How Monitoring Works: events, log items, late and failed runs.
- Naming Tasks: how names are derived and why they matter.
- Oh Dear Setup: get notified when a task does not run.
- Configuration: every config key and environment variable.
- Troubleshooting: common problems and quirks.