- What is spatie/laravel-short-schedule used for?
- It schedules Laravel Artisan commands at sub-minute frequencies such as every second, every 30 seconds, or every half second. It runs a separate long-running process powered by ReactPHP so short tasks do not delay Laravel's native scheduler. Use it for short operational commands like polling, cache warming, heartbeat checks, or lightweight queue helpers, not as a replacement for queues or event-driven jobs.
- How do I install and configure spatie/laravel-short-schedule in Laravel?
- Install it with Composer, then define schedules using the ShortSchedule facade in routes/console.php or the shortSchedule method in your console kernel. Run php artisan short-schedule:run under Supervisor or systemd. The worker must be restarted after schedule changes or deployments. Check version compatibility carefully because the latest 1.7.0 release requires PHP 8.3 or newer and supports Laravel 13 while dropping Laravel 10 and 11.
- Does laravel-short-schedule support Laravel 10 or 11?
- The latest 1.7.0 release drops Laravel 10 and 11 and adds Laravel 13 support, requiring PHP 8.3 or newer. If you need Laravel 10 or 11, pin an earlier compatible package release. Check the release notes and your PHP version before upgrading. This matters if your application is still on an older Laravel version.
- How is spatie/laravel-short-schedule different from Laravel's native scheduler?
- Laravel's native scheduler runs commands at most once per minute through schedule:run. Short schedule uses a separate ReactPHP event loop and one periodic timer per command to launch commands more often, including sub-second intervals. That separation means short tasks never delay or get delayed by your regular schedule. It also adds a second scheduling runtime that must be supervised and restarted when schedules change.
- Can short-scheduled commands overlap or run more than once?
- Commands overlap by default unless you use withoutOverlapping, so a long-running command can be launched again before its previous run finishes. Across multiple app instances, duplicate execution can occur unless you use onOneServer with a shared cache and lock backend. Use both options for commands that must not run concurrently or on more than one node. Plan for lock or cache outages that could affect duplicate prevention.
- How do I run short-schedule in production with Supervisor?
- Run php artisan short-schedule:run as a long-lived process supervised by Supervisor, systemd, or an equivalent process monitor. Configure the supervisor to restart the worker, especially if you use --lifetime to mitigate memory leaks. Restart the worker on deployment or whenever schedule definitions change. Monitor process health and command failures externally because the package provides no built-in alerting or execution dashboard.
- What are the risks of high-frequency short-scheduled commands?
- High frequency can create process fan-out and host resource pressure if commands are slow or overlap. Constraints and event listeners run inside the ReactPHP loop, so slow when callbacks or event handlers can delay every short-scheduled task. Keep command runtime short, move heavy work to queues, and set a clear concurrency budget. Use withoutOverlapping and onOneServer where appropriate.
- How do I test short-scheduled commands in Laravel?
- Keep the scheduled Artisan command logic testable independently with Laravel's usual command and feature tests. Test schedule definitions separately if your application exposes them, and verify constraints and event listeners behave as expected. The long-running ReactPHP worker is operational infrastructure, so integration tests should focus on command idempotency and overlap behavior. Avoid relying on real sub-second timing in unit tests.
- Does spatie/laravel-short-schedule work with multiple servers?
- It can run on multiple app instances, but each worker will launch its own timers and commands unless onOneServer is enabled. onOneServer depends on a shared cache or lock backend so only one node executes a given task. Even then, plan for duplicate execution risks during cache outages or lock failures. Use a single worker where possible or coordinate through shared locks.
- What alternatives should I consider before using laravel-short-schedule?
- First check whether native Laravel scheduling, cron, queues, or event-driven jobs can meet the actual requirement. If the need is truly sub-minute and command-based, this package is a focused option. Alternatives include custom supervised workers, system cron with sleep loops, or queue-based recurring jobs depending on your architecture. Choose based on operational ownership, observability, and whether commands are short and idempotent.