Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Short Schedule

Laravel Short Schedule Laravel Package

spatie/laravel-short-schedule

Run Laravel Artisan commands at sub-minute intervals (every second or even 0.5s). Adds a short-scheduler powered by a ReactPHP event loop, running separately from schedule:run so high-frequency tasks don’t block or get delayed.

View on GitHub
Deep Wiki
Context7

Schedule artisan commands to run using a sub-minute frequency

Frequently asked questions about Laravel Short Schedule
How do I schedule an Artisan command to run every 30 seconds in Laravel?
Use the `ShortSchedule` facade in `routes/console.php` or the `shortSchedule()` method in your `Console/Kernel.php`. Call `everySeconds(30)` on your command definition, like `ShortSchedule::command('analytics:process')->everySeconds(30)`.
Does spatie/laravel-short-schedule work with Laravel 11?
No, Laravel 11+ includes native sub-minute scheduling. This package is only needed for Laravel 9–13 (excluding 10/11). Check the [Laravel docs](https://laravel.com/docs/11.x/scheduling#sub-minute-scheduled-tasks) for alternatives.
Can I run commands at sub-second intervals (e.g., every 0.5 seconds)?
Yes, the package supports fractional seconds. Use `everySeconds(0.5)` to run a command every half-second. This is useful for high-frequency tasks like real-time IoT monitoring or live analytics.
How do I install and set up spatie/laravel-short-schedule?
Run `composer require spatie/laravel-short-schedule`, then add the `shortSchedule()` method to your `Console/Kernel.php` or define tasks in `routes/console.php`. Finally, run `php artisan short-schedule:run` to start the scheduler.
Will this package block my Laravel application or use excessive resources?
No, it runs in a separate process using Symfony’s `Process` component, avoiding blocking. However, for long-running tasks, monitor memory usage and set up a process manager like Supervisor to enforce restarts (e.g., every 60 seconds).
Can I schedule commands conditionally (e.g., only on certain days or environments)?
Yes, use constraints like `when()`, `between()`, or `environments()`. For example, `ShortSchedule::command('backup')->everyMinute()->when(fn() => config('app.environment') === 'production')`.
How do I handle failures or retries for short-scheduled tasks?
Use `withoutOverlapping()` to prevent overlapping executions and implement retries in your command logic. Log process IDs for debugging and consider exponential backoff for transient failures.
Is there a way to monitor or log short-scheduled tasks?
Yes, listen to `ShortScheduledTaskStarting` and `ShortScheduledTaskStarted` events for observability. Use async logging (e.g., Laravel Queues) to avoid blocking the scheduler. Tools like Prometheus can track execution metrics.
Does this package work with Lumen or other lightweight Laravel frameworks?
Yes, but you’ll need to manually copy the `ShortScheduleRunCommand` to your project. The package provides explicit instructions for Lumen integration in the [README](https://github.com/spatie/laravel-short-schedule).
What are the alternatives if I’m on Laravel 11+ or want to avoid this package?
Laravel 11+ supports sub-minute scheduling natively. For older versions, consider cron-based solutions (e.g., `* * * * * * php artisan command:run`) or queue-based polling. Evaluate trade-offs like precision and resource usage.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai