Laravel队列只能在手动启动时工作,不能使用内核命令



我有以下Kernel.php:

<?php
namespace AppConsole;
use IlluminateConsoleSchedulingSchedule;
use IlluminateFoundationConsoleKernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param  IlluminateConsoleSchedulingSchedule  $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
Log::info("hit");
$schedule->command('queue:restart')->everyFiveMinutes();
$schedule->command('queue:work')->name('queue_work_name')->withoutOverlapping()->runInBackground();
}
}

和一个cron作业设置为每分钟运行一次…它正确地打印了日志中的"hit",但是没有队列正在运行的迹象…然而,如果我去终端并运行php artisan queue:work --once,它只是工作良好

我错过了什么

您是否已将此代码添加到crontab中?

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

以上代码检查计划命令并执行它们。

在linux中使用crontab -e打开crontab。

最新更新