How to schedule commands to run every few seconds in a Laravel app
Using our spatie/laravel-short-schedule package you can schedule commands at sub-minute intervals.
// in app\Console\Kernel.php
protected function shortSchedule(\Spatie\ShortSchedule\ShortSchedule $shortSchedule)
{
// this command will run every second
$shortSchedule->command('artisan-command')->everySecond();
// this command will run every 30 seconds
$shortSchedule->command('another-artisan-command')->everySeconds(30);
// this command will run every half a second
$shortSchedule->command('another-artisan-command')->everySeconds(0.5);
}
In this video, I show you how you can use the package.
I've also recorded another video that shows how the package works under the hood (spoiler: we'll use ReactPHP).
What are your thoughts on "How to schedule commands to run every few seconds in a Laravel app"?