Laravel Cron Job计划的任务无法正常工作

时间:2019-05-13 22:35:41

标签: laravel cron

我正在尝试通过计划任务自动更新状态。我不确定如何调试问题,因为我是Cron作业的新手。我创建了cronjob并将其添加到内核中。但是,它不会执行。

cronOffer.php

protected $signature = 'update:offer';
protected $description = 'update expired offers status ';

public function __construct()
{
    parent::__construct();
}

public function handle()
{
    $RSS = Rss::where('RSS_Status', '!=', 6)->first();
    $Projects = Project::where('RSS_ID', $RSS->RSS_ID)->get();

    foreach ($Projects as $Project) {

        $applications = Application::where(['A_ID' => $Project->A_ID, 'Status_ID' => 2])->get();
        foreach ($applications as $application) {
            $current_time = Carbon::now();
            $OfferDeadline = $Project->updated_at; //->addDays(2)

            if ($current_time >= $OfferDeadline) {
                $application->Status_ID = 6;
                $application->save();
            }
            $next = $application->S_Rank + 1;

            if ($application->Status_ID === 6) {
                $waiting = Application::where(['A_ID' => $Project->A_ID, 'Status_ID' => 3, 'S_Rank' => $next])->first();
                $waiting->Status_ID = 2;
                $waiting->save();
            }
        }
    }
}

内核

protected $commands = [
    // Register corn commands (scheduled)
    Commands\cronOffer::class
];

protected function schedule(Schedule $schedule)
{
    //->dailyAt('09:30');
    $schedule->command('update:offer')
        ->everyMinute();
}

protected function commands()
{
    require base_path('routes/console.php');
}

0 个答案:

没有答案