在共享服务器上使用 Laravel 的 Cron 会出现此错误,为什么?

Working Cron with Laravel on a shared server, gives this error, why?

下午好,

我正在尝试 运行 此 cron 与 laravel 5.6 中的队列一起工作,在与 laravel 相比的主机中,但我收到以下错误:

[root@s19 ~]# /usr/local/bin/php /home/user/myweb/artisan schedule:run

   InvalidArgumentException  : 5 is not a valid position

  at /home/nigmacod/nigmacode/vendor/dragonmantank/cron-expression/src/Cron/FieldFactory.php:46
    42|                 case 4:
    43|                     $this->fields[$position] = new DayOfWeekField();
    44|                     break;
    45|                 default:
  > 46|                     throw new InvalidArgumentException(
    47|                         $position . ' is not a validposition'
    48|                     );
    49|             }
    50|         }

  Exception trace:

  1   Cron\FieldFactory::getField()
      /home/user/myweb/vendor/dragonmantank/cron-expression/src/Cron/CronExpression.php:153

  2   Cron\CronExpression::setPart("*")
      /home/user/myweb/vendor/dragonmantank/cron-expression/src/Cron/CronExpression.php:136

这是我内核文件中的函数调度:

 protected function schedule(Schedule $schedule)
        {

            $schedule->command('queue:work --tries=3')
            ->cron('* * * * * *')
            ->withoutOverlapping();
        }

这将是我在 cpanel 中配置的 cron,因此它每分钟 运行s:

/usr/local/bin/php /home/user/myweb/artisan schedule:run >> /dev/null 2>&1

->cron('* * * * * *') 是你的问题。

Cron 需要五个值 - 分钟、小时、月中的某天、月份和星期几。您提供了第六个,它不知道如何处理它。

将其更改为 ->cron('* * * * *')(或为了更好的可读性,->everyMinute()),您就大功告成了。