Task Scheduling

Schedule recurring tasks with the scheduler

Task scheduling replaces cron entries with an expressive PHP API defined in your application.

Register scheduled tasks in your console kernel using commands, closures, or job classes.

Single cron entry needed
* * * * * php artisan schedule:run
Task timeline
emails:senddaily
stats:updatehourly
cache:cleareveryMinute
backup:rundailyAt 03:00
Common frequencies
->daily()Midnight
->hourly()Every hour
->everyMinute()Every min
->weekly()Sunday 00:00
PHP
// app/Console/Kernel.php
protected function schedule(Schedule $schedule): void {
    // Schedule a command
    $schedule->command('emails:send')->daily();

    // Schedule a closure
    $schedule->call(function () {
        DB::table('temp')->delete();
    })->weekly();

    // Schedule a job
    $schedule->job(new ProcessReports)->hourly();
}