首页 > 解决方案 > Laravel schedule:run 在添加到 cron 作业时不起作用

问题描述

我已经做了一个命令并安排它每 30 分钟一次。当我运行php artisan schedule:run它时,它工作得很好并返回了预期的结果,但是当我在我的实时服务器上配置它时,我的 cron 作业确实运行了,但它没有重新调整成功消息,而是返回我的 laravel 项目中所有可用命令的列表。这就是我正在做的事情。

命令内核:

$schedule->command('update:callLogs')
            ->everyMinute();

Cron 条目:

/usr/bin/php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run

这就是我得到的回应

Laravel 框架 5.8.38

Usage:
command [options] [arguments]

Options:
 -h, --help            Display this help message
 -q, --quiet           Do not output any message
 -V, --version         Display this application version
  --ansi            Force ANSI output
  --no-ansi         Disable ANSI output
 -n, --no-interaction  Do not ask any interactive question
  --env[=ENV]       The environment the command should run under
 -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
 (List of all availabe commands)

任何帮助都感激不尽。

编辑 现在我的命令看起来像这样

* * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm && php artisan update:callLogs

但是得到相同的响应,而当我复制相同的命令并使用 putty 运行相同的命令时,它工作得很好。现在已经一个星期了,我仍然坚持这个 cron 事情。

标签: phplaravelcron

解决方案


我通过指定 PHP 的路径而不是仅使用php.

由此:cd /home/foobar && php artisan schedule:run

对此:cd /home/foobar && /usr/local/bin/php artisan schedule:run

这阻止了我获取可用工匠命令的列表,并给了我正确的输出。

我可以看到您似乎已经尝试过,但我认为其他人也会遇到这种情况。我想您的问题与您使用的 PHP 版本无法正确运行 PHP 脚本有关。也许是 CLI 的 opcache 东西?


推荐阅读