Laravel Scheduler开始运行,但未完成且未显示任何错误

时间:2019-12-18 11:45:52

标签: laravel command scheduler

我的laravel调度程序有一些问题。我有几个每晚运行的命令,有些仅偶尔运行:

 $schedule->command('removeSpacesFromPhoneNumbers:now')->dailyAt('00:30')->withoutOverlapping(10);

 $schedule->command('setContentVisibility:setvisibility')->dailyAt('00:00')->withoutOverlapping(10);

 $schedule->command('sendNewUserNotifications:send')->dailyAt('01:00')->withoutOverlapping(10);

 $schedule->command('removeUnfinishedRegistrations:now')->monthly()->withoutOverlapping(10);

 $schedule->command('setInstitutionID:now')->dailyAt('01:30')->withoutOverlapping(10);

 $schedule->command('createAngeboteIndex:all')->dailyAt('03:00')->withoutOverlapping(10);

 $schedule->command('contentsToApp:now')->dailyAt('02:30')->withoutOverlapping(10);

 $schedule->command('calculateDateTimeTable:now')->weeklyOn(1, '3:30')->withoutOverlapping(10);

调度程序运行得很好,并在设置的时间触发了命令,但是命令直到最后才运行。例如,我有一个命令,每晚检查一次某种内容类型的所有内容,以确定某个特定内容是否应保持公开状态:

  public function handle()
{
    Log::info("Set content visibility start");

    $contents = Content::All();

    $nowDate = date("Y-m-d");
    $nowDateTime = date("Y-m-d H:i:s");

    foreach ($contents as $key => $content) {

        if($content->tname()=='institution'){
            continue;
        }

        if(isset($content->public_to) || isset($content->public_from)){

            if(($content->public_to < $nowDateTime || $content->public_from > $nowDateTime) && $content->view_status==1){
                $content->view_status=0;
                $content->save();
            }

            if($content->public_from <= $nowDateTime && $content->public_to >= $nowDateTime && $content->view_status==0){
                $content->view_status=1;
                $content->save();
            }


            $dateFrom = date("Y-m-d",strtotime($content->public_from));
            $dateTo = date("Y-m-d",strtotime($content->public_to));

            $to = explode("-", $dateTo);
            $from = explode("-", $dateFrom);

            if($to[0]=="1970" && $from[0]=="1970"){

                $now = explode("-",date("Y-m-d"));

                if(($to[1]>=$now[1] && $to[2]>=$now[2]) && ($from[1]<=$now[1] && $from[2]<=$now[2])){
                    $content->view_status=1;
                    $content->save();
                    continue;
                }
                else{
                    $content->view_status=0;
                    $content->save();
                    continue;
                }
            }
        }

        if($content->datespan()!=null){
            if($content->datespan()->end < $nowDate){
               $content->view_status=0;
               $content->save();
           }
       }

       /*Deactivate Contents that have an appointment at a certain date and that are expired*/
       $last = $content->lastAppointment();
       if(isset($last) && $last->date<$nowDate){
        $content->view_status=0;
        $content->save();
    }

    $lf=$content->getProperty('offer_laufender_einstieg');
    if($lf == "" || $lf==false){
        $first = $content->firstAppointment();
        if(isset($first) && $first->date<=$nowDate){
            $content->view_status=0;
            $content->save();
        }
    }
}
Log::info("Set content visibility finished");

}

如您所见,我在每次运行的开始和结束时都添加了一个Log-entry。我的日志在开头显示条目,但从不显示标记命令结束的条目。当我在没有调度程序的情况下运行命令时,一切正常。

我在这里想念什么?我的理解如何调度命令是否存在问题?非常感谢您的帮助!

亲切的问候

亚历克斯

0 个答案:

没有答案