- How do I install spatie/laravel-schedule-monitor in a Laravel app?
- Run composer require spatie/laravel-schedule-monitor, publish the schedule-monitor migrations and config, then run php artisan migrate. Add schedule-monitor:sync to your deploy script so new scheduled tasks are registered, and use schedule-monitor:list to review execution history. The package creates new tables only and makes no destructive schema changes.
- Does spatie/laravel-schedule-monitor support Laravel 8?
- Yes, but Laravel 8 requires installing v2 with composer require spatie/laravel-schedule-monitor:^2. Newer Laravel applications can use the current major version. Check the PHP constraint and config-cache path in your target app before committing.
- How does laravel-schedule-monitor record scheduled task runs?
- It hooks Laravel scheduler events for starting, finished, failed, and skipped tasks and writes rows to monitored_scheduled_tasks and monitored_scheduled_task_log_items. Each log item can include start and end times, memory usage, duration, and optional output. This gives you a queryable execution history without an agent, daemon, or sidecar.
- Why is my scheduled task missing from schedule-monitor:list?
- The most common cause is not running schedule-monitor:sync after adding or renaming a task, especially when the deploy step is skipped, so the task remains silently unmonitored. Closures and Schedule::call entries need an explicit monitorName() because the package cannot infer a stable name. Renaming a task also deletes its existing log history and creates a fresh monitor.
- How do I sync my Laravel schedule with Oh Dear?
- Configure your Oh Dear credentials in the published schedule-monitor config, then run php artisan schedule-monitor:sync. The command creates or updates Oh Dear cron monitors for your Laravel scheduled tasks and enables alerts when a task fails or runs late. Run it as part of every deploy so newly added tasks are covered.
- What is the difference between schedule-monitor:sync and --keep-old?
- By default schedule-monitor:sync is destructive: it removes Oh Dear cron monitors that are not defined by your Laravel schedule. With --keep-old it will not remove any existing monitors, which preserves external cron jobs but also never cleans up stale monitors. Choose deliberately based on whether Oh Dear or Laravel is the source of truth for all cron jobs.
- How do I fix false late alerts for long-running scheduled tasks?
- The default grace time is 5 minutes, which is too tight for long reports, exports, or sync jobs. Tune graceTimeInMinutes() per scheduled task to match realistic runtimes and avoid alert noise. Review tasks that routinely exceed 5 minutes and assign values with the team that owns the schedule.
- How do I prune old schedule monitor log entries?
- Add the prune command for MonitoredScheduledTaskLogItem to your schedule, for example model:prune --model=MonitoredScheduledTaskLogItem. Without pruning, high-frequency tasks can generate large log tables quickly. A per-minute task can create roughly 1,400 rows per day before start and end duplication.
- Does laravel-schedule-monitor work with Horizon and spatie/laravel-multitenancy?
- Horizon users get a silencing config and should confirm it is enabled. With spatie/laravel-multitenancy, add PingOhDearJob to not_tenant_aware_jobs or Oh Dear dispatch will fail in tenant context. The core database logging path remains in-process and does not require a queue worker.
- What are alternatives to spatie/laravel-schedule-monitor?
- Alternatives include external cron monitors such as Oh Dear, Healthchecks.io, and Cronitor, plus existing error tracking like Sentry, Datadog, or Horizon for failed jobs. This package is strongest when you want Laravel-native execution history plus optional Oh Dear sync. Remember it cannot report that the scheduler itself stopped; an external heartbeat is still needed to close that gap.