问题描述
我有自定义Artisan命令,在本地以及在我的生产服务器上运行,当我SSH,但任何cron作业不可用。
I have custom Artisan commands that run locally as well as on my production server when I am SSH'd in, but are unavailable to any cron jobs. I've even tried running it as the user the cron job runs as and it works fine from my console.
当我运行 php artisan
When I run php artisan
in the above settings, my custom commands are listed and available. However, they are not listed when I run php artisan
as a cron job.
定制命令 php artisan subjects:calculate
作为cron作业会导致以下错误:
Furthermore, trying to run the custom command php artisan subjects:calculate
as a cron job results in the following error:
[InvalidArgumentException]
在subject命名空间中没有定义命令。
[InvalidArgumentException]
There are no commands defined in the "subjects" namespace.
推荐答案
我在争取同样的错误,我找到了解决方案。
首次失败的尝试
I was fighting with the same error and I found the solution.First failed attempts
*/5 * * * * /usr/bin/php /home/mysite/public_html/artisan my:command
*/5 * * * * php /home/mysite/public_html/artisan my:command
解决方案
*/5 * * * * /usr/local/bin/php /home/mysite/public_html/artisan my:command
这篇关于自定义Laravel Artisan命令不能通过cron作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!