Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
513 views
in Technique[技术] by (71.8m points)

php - Custom Laravel Artisan command not available through cron job

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.

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.

Furthermore, trying to run the custom command php artisan subjects:calculate as a cron job results in the following error:

[InvalidArgumentException]
There are no commands defined in the "subjects" namespace.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Solution

*/5 * * * * /usr/local/bin/php /home/mysite/public_html/artisan my:command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...