我在 App\Console\Kernel
上设置了以下 Laravel 命令:
protected function schedule(Schedule $schedule) {
$schedule->command('command:daily-reset')->daily();
$schedule->command('command:monthly-reset')->monthly();
}
然后,在我的服务器上,我设置了一个每天运行一次的 cron 作业(在 00:00)。
0 0 * * * php /home/privates/public_html/staging/current/artisan schedule:run
我的 cron 作业每晚都成功运行,但日志只是说:“没有计划的命令准备好运行。”
我究竟做错了什么?我希望我的 daily
命令每晚运行。
谢谢!
原文由 user1832945 发布,翻译遵循 CC BY-SA 4.0 许可协议
您是否尝试手动运行命令?
运行
php artisan
并查看您的命令是否已注册。如果你已经注册了你的命令,你应该在可用的 artisan 命令列表下看到
command:daily-reset
和command:monthly-reset
。如果您没有看到它们,请继续注册您的命令,方法是将其添加到
commands
属性中可用的app/Console/Kernel.php
。将 crontab 条目更改为
* * * * * php /home/privates/public_html/staging/current/artisan schedule:run