我有点恶梦,需要crontab / cronjob来运行Artisan命令。
I'm having a bit of a nightmare getting a crontab/cronjob to run an Artisan command.
我还有另一个通过cronjob运行的Artisan命令,但这没有问题第二个命令将无法运行。
I have another Artisan command running via cronjob no problems but this second command won't run.
首先,当我执行 crontab -e并编辑文件以使其包含以下内容时:
Firstly, when I do 'crontab -e' and edit the file to contain:
0 0 * * * /usr/local/bin/php /home/purple/public_html/artisan feeds:sendcronjob根本不运行。
The cronjob doesn't run at all.
如果我去cPanel并在其中添加cronjob ,它运行但我收到以下错误:
If I go to cPanel and add the cronjob there, it runs but I receive the following error:
open(public/downloads/feeds/events.csv): failed to open stream: No such file or directory问题是文件存在且目录具有正确的权限。如果我以root用户身份通过SSH或以紫色用户(php artisan feeds:send)登录时运行该命令,则该命令可以正常运行,并且可以顺利完成任务。
The thing is the file exists and the directories have the correct permissions. If I run the command when logged in via SSH as root or the user purple (php artisan feeds:send) the command runs flawlessly and completes its tasks no problem.
如果在cPanel中,我编辑cronjob以使用:
If in cPanel, I edit the cronjob to use:
0 0 * * * php /home/purple/public_html/artisan feeds:send我收到以下错误:
There are no commands defined in the "feeds" namespace.有趣的是,我的另一个命令已在crontab文件中注册并且可以使用,并且在
The funny thing is that my other command is registered in the crontab file and works and has no reference in cPanel at all.
任何帮助将不胜感激。为简洁起见,我包括了命令和命令使用的模型。
Any help would be much appreciated. Just for brevity I have included the command and model that the command uses.
Feed.php模型:
Feed.php Model:
laravel.io/bin/1e2n
DataFeedController.php控制器:
DataFeedController.php Controller:
http:// laravel.io/bin/6x0E
SendFeeds.php命令:
SendFeeds.php Command:
laravel.io/bin/BW3d
开始/artisan.php:
start/artisan.php:
laravel.io / bin / 2xV3
FeedInterface.php接口:
FeedInterface.php Interface:
laravel.io/bin/LxnO
如您所见
推荐答案看起来我必须先运行cd进入脚本目录,然后运行com mand,现在算出来就很有意义了。
Well it looks like I had to cd in to the script directory first before running the command, which now after working it out it makes sense. Easy when you know how eh!
* * * * * cd /home/purple/public_html/ && /usr/local/bin/php artisan feeds:send更多推荐
通过Cronjob发出运行工匠命令
发布评论