在本地运行 Laravel Scheduler 时,可能会遇到无法执行创建的命令的问题。这通常是由于未正确设置定时任务导致的。为了解决这个问题,你可以按照下面的步骤进行操作:
$schedule->command('my:command')->daily();
php artisan schedule:work
在命令行中输入:
crontab -e
添加以下代码:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
php artisan schedule:list
经过以上步骤的检查和操作,你应该能够在本地环境中成功运行 Laravel Scheduler。