为什么laravel任务调度器在升级到laravel9后两次运行命令



因为我们已经将我们的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

似乎两个用户rootubuntu正在运行相同的命令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

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

最新更新