Scheduler
| Schedule commands | |
| Frequencies | |
| One cron line | |
| List tasks |
Schedule commands
Cron jobs move into code with the scheduler, so servers need only one timer. Register each command on the schedule object with the wanted rhythm.
Keep the command itself thin and put the logic in services that are easy to test.
$schedule->command("reports:daily")->daily();
Frequencies
Frequencies read like plain words: hourly, daily, or dailyAt with a clock time. Chain one frequency per command and add more lines for more jobs.
Times use the app timezone, so confirm it matches the server before launch.
$schedule->command("reports:daily")->dailyAt("08:00"); $schedule->command("stats:refresh")->hourly();
One cron line
A single server cron wakes Laravel each minute, and Laravel decides what is due. Point the cron at the schedule runner and nothing else.
Every later job needs code only, never a new cron entry.
* * * * * php artisan schedule:run
List tasks
List prints every scheduled task with its rhythm in one table. Run it after editing the schedule to confirm names and times.
A missing row means the registration code never ran, so check the schedule file first.
php artisan schedule:list
0 8 * * * reports:daily 0 * * * * stats:refresh
Next: Filesystem
Article author: Arthur Isaev