当我通过 SSH 连接时,我有自定义的 Artisan 命令在本地以及我的生产服务器上运行,但对任何 cron 作业都不可用.我什至尝试以运行 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
时,我的自定义命令会列出并可用.但是,当我将 php artisan
作为 cron 作业运行时,它们没有列出.
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 subject:calculate
作为 cron 作业运行会导致以下错误:
Furthermore, trying to run the custom command php artisan subjects:calculate
as a cron job results in the following error:
<代码>[无效参数异常]
主题"命名空间中没有定义命令.
我遇到了同样的错误,我找到了解决方案.第一次失败的尝试
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
这篇关于无法通过 cron 作业使用自定义 Laravel Artisan 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!