【问题标题】:why laravel task schedular running commands twice after upgrade to laravel 9?为什么升级到 laravel 9 后 laravel 任务调度程序运行命令两次?
【发布时间】:2022-10-24 06:29:31
【问题描述】:

由于我们已将 laravel 项目从 laravel 8 升级到 laravel 9。我们面临的问题是 kernel.php 中提到的所有命令和作业都运行了两次,因此系统在 DB 中创建了重复的条目。我们没有对代码进行任何更改。

我们还将 ubuntu 版本从 16 升级到 20。

我通过这个命令crontab -e检查了cron文件,但是只有一次写入的命令。也许从其他地方的服务器上运行另一个命令的ubuntu。

Kernel.php

 protected function schedule(Schedule $schedule)
    {

        //POD STATS update job
        $schedule->job(new PodStatsJob)->everyTenMinutes();
        //Consignment table backup job

      

        #Pickup Email Reminder
        $pickup_reminder_time = substr(getSingleOrganisationSetting("pickup_reminder_time"), 0, 5) ?? '07:00';
      

      
        // $schedule->command('conveyor:indexing')->dailyAt($conveyor_consignment_indexing);

        
    }

当我用这个命令检查时ps aux | grep "artisan schedule:run"

我明白了

root     1331614  0.0  0.0   2616   528 ?        Ss   15:00   0:00 /bin/sh -c cd /var/www/html/coldxlogistics && php artisan schedule:run >> /dev/null 2>&1
root     1331616  0.0  0.9 216924 77220 ?        S    15:00   0:03 php artisan schedule:run
root     1345894  0.0  0.0   2616   592 ?        Ss   17:39   0:00 /bin/sh -c cd /var/www/html/coldxlogistics && php artisan schedule:run >> /dev/null 2>&1
ubuntu   1345895  0.0  0.0   2616   600 ?        Ss   17:39   0:00 /bin/sh -c cd /var/www/html/coldxlogistics && php artisan schedule:run >> /dev/null 2>&1
root     1345896 27.0  0.9 216924 79020 ?        S    17:39   0:00 php artisan schedule:run
ubuntu   1345897 28.0  0.9 216924 78944 ?        S    17:39   0:00 php artisan schedule:run
ubuntu   1345911  0.0  0.0   8484  2428 pts/0    S+   17:39   0:00 grep --color=auto artisan schedule:run

【问题讨论】:

  • 也许你正在运行 schedule:work 和 schedule:run 一起?
  • @FrancescoGallo 我更新了问题,请看一下

标签: laravel cron laravel-8 laravel-9


【解决方案1】:

好像有两个用户ubuntu正在运行相同的命令php artisan schedule:run

root     1345896 27.0  0.9 216924 79020 ?        S    17:39   0:00 php artisan schedule:run
ubuntu   1345897 28.0  0.9 216924 78944 ?        S    17:39   0:00 php artisan schedule:run

您可能只需要在一个用户上运行该服务。

【讨论】:

    猜你喜欢
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 2017-01-31
    • 2019-02-15
    • 1970-01-01
    • 1970-01-01
    • 2022-08-10
    • 2020-11-06
    相关资源
    最近更新 更多