通过Cronjob发出运行工匠命令

编程入门 行业动态 更新时间:2024-10-24 20:13:39
本文介绍了通过Cronjob发出运行工匠命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有点恶梦,需要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:send

cronjob根本不运行。

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发出运行工匠命令

本文发布于:2023-07-16 04:10:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117704.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工匠   命令   Cronjob

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!