🔴 Laravel
Intermediate
What is Task Scheduling in Laravel?
Answer
Laravel's task scheduler allows you to fluently define scheduled commands within the application itself, instead of managing multiple cron entries. Define schedules in app/Console/Kernel.php's schedule() method: $schedule->command("emails:send")->daily(), $schedule->job(new ReportJob)->weekdays()->at("08:00"), $schedule->call(fn() => DB::table("logs")->delete())->monthly(). Frequency methods: everyMinute(), hourly(), daily(), weekly(), cron("* * * * *"). Constraints: ->weekdays(), ->between("8:00", "17:00"), ->when(fn() => $condition). Only one cron entry needed on the server: * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1. Prevent overlapping: ->withoutOverlapping().