What is Task Scheduling in Laravel?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
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().
Common Mistake
A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.