Interview frequency: …
Short answer
Create a command with make:command and implement its logic in handle(); schedule it in routes/console.php instead of adding multiple Cron entries to the server.
Explanation
Previously, running several tasks required adding a Cron line for each script on the server. In Laravel, add just one Cron entry: * * * * * php artisan schedule:run. It checks the tasks scheduled in code and runs those that are due, with options such as withoutOverlapping to prevent a task from running again before it finishes and onOneServer to run it on one server only.
Code example
Schedule::command('reports:generate')
->dailyAt('02:00')
->withoutOverlapping()
->onOneServer();Common mistakes
- Forgetting withoutOverlapping for long-running tasks, causing duplicate instances to compete for the same data and exhaust server resources.