cpanel 共享主机上的 Laravel 调度作业不起作用

时间:2021-05-27 05:18:24

标签: laravel cron cpanel

我已经在我的应用程序中实现了 laravel 队列,但是在共享主机中使用 cPanel 调度 cron 作业时遇到了问题。

<块引用>

共享主机上的目录结构是:

  • 项目
  • public_html

project/app/console/kernel.php 在那里我更新了调度命令。

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
     $schedule->command('queue:work --stop-when-empty')
              ->everyMinute();
}

cpanel cron 中的命令

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

注意:在终端中运行 schedule 命令时,这在我的本地机器上运行良好。

php artisan schedule:run

输出:

Running scheduled command: '/usr/bin/php7.4' 'artisan' queue:work --stop-when-empty > '/dev/null' 2>&1

1 个答案:

答案 0 :(得分:1)

您必须在 cpanel cron 命令中定义项目 artisan 文件

/usr/local/bin/php /path/to/file/artisan schedule:run >> /dev/null 2>&1