任务调度程序无法在实时服务器CPANEL上使用

发布于 2025-02-08 15:03:01 字数 4274 浏览 3 评论 0原文

当我在CPANEL上设置玉米作业时,我的CRON工作没有在实时服务器上工作。我每分钟向用户发送通知。在实时服务器上,我尝试了终端但不起作用。

这是我调度程序的代码。

 protected function schedule(Schedule $schedule)
{
    
    $schedule->call(function(){
        $morning_time = inpatient_prescription::whereRaw('morning_time + INTERVAL 5 MINUTE <= CURRENT_TIME() AND date = CURRENT_DATE AND morning_status = 0')
        ->join('patients','patients.id','inpatient_prescriptions.patient_id')
        ->join('departments','departments.id','inpatient_prescriptions.department_id')
        ->join('wards','wards.id','ward_id')
        ->get();

        $evening_time = inpatient_prescription::whereRaw('evening_time + INTERVAL 5 MINUTE <= CURRENT_TIME() AND date = CURRENT_DATE AND evening_status = 0')
        ->join('patients','patients.id','inpatient_prescriptions.patient_id')
        ->join('departments','departments.id','inpatient_prescriptions.department_id')
        ->join('wards','wards.id','ward_id')
        ->get();

        $night_time = inpatient_prescription::whereRaw('night_time + INTERVAL 5 MINUTE <= CURRENT_TIME() AND date = CURRENT_DATE AND night_status = 0')
        ->join('patients','patients.id','inpatient_prescriptions.patient_id')
        ->join('departments','departments.id','inpatient_prescriptions.department_id')
        ->join('wards','wards.id','ward_id')
        ->get();

        if($morning_time->count()!=0){
            $user1 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_primary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $user2 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_secondary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();


            $new = $morning_time;
            $user1->notify(new dos_reminder($new));
            $user2->notify(new dos_reminder($new));
            Notification::send($user1, new SlackNotification($new));
            event(new MessageNotification('Morning time query executed'));
            Log::info('Working');
        }
        if($evening_time->count()!=0){
            $user1 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_primary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $user2 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_secondary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $new = $evening_time;
            $user1->notify(new dos_reminder($new));
            $user2->notify(new dos_reminder($new));
            Notification::send($user1, new SlackNotification($new));

            event(new MessageNotification('evening time query executed'));
            Log::info('Working');
        }
        if($night_time->count()!=0){
            $user1 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_primary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $user2 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_secondary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();


            $new = $night_time;
            $user1->notify(new dos_reminder($new));
            $user2->notify(new dos_reminder($new));
            Notification::send($user1, new SlackNotification($new));
            event(new MessageNotification('Night time query executed'));
            Log::info('Working');
        }
    })->everyMinute();
    
}

这是我在cpanel中添加的玉米作业命令,

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

它没有执行。请帮忙

My cron job is not working on the live server as I have set up the corn job on cPanel. I am sending notifications to users every minute. On live server I tried from terminal but not working.

Here is the code of my scheduler.

 protected function schedule(Schedule $schedule)
{
    
    $schedule->call(function(){
        $morning_time = inpatient_prescription::whereRaw('morning_time + INTERVAL 5 MINUTE <= CURRENT_TIME() AND date = CURRENT_DATE AND morning_status = 0')
        ->join('patients','patients.id','inpatient_prescriptions.patient_id')
        ->join('departments','departments.id','inpatient_prescriptions.department_id')
        ->join('wards','wards.id','ward_id')
        ->get();

        $evening_time = inpatient_prescription::whereRaw('evening_time + INTERVAL 5 MINUTE <= CURRENT_TIME() AND date = CURRENT_DATE AND evening_status = 0')
        ->join('patients','patients.id','inpatient_prescriptions.patient_id')
        ->join('departments','departments.id','inpatient_prescriptions.department_id')
        ->join('wards','wards.id','ward_id')
        ->get();

        $night_time = inpatient_prescription::whereRaw('night_time + INTERVAL 5 MINUTE <= CURRENT_TIME() AND date = CURRENT_DATE AND night_status = 0')
        ->join('patients','patients.id','inpatient_prescriptions.patient_id')
        ->join('departments','departments.id','inpatient_prescriptions.department_id')
        ->join('wards','wards.id','ward_id')
        ->get();

        if($morning_time->count()!=0){
            $user1 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_primary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $user2 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_secondary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();


            $new = $morning_time;
            $user1->notify(new dos_reminder($new));
            $user2->notify(new dos_reminder($new));
            Notification::send($user1, new SlackNotification($new));
            event(new MessageNotification('Morning time query executed'));
            Log::info('Working');
        }
        if($evening_time->count()!=0){
            $user1 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_primary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $user2 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_secondary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $new = $evening_time;
            $user1->notify(new dos_reminder($new));
            $user2->notify(new dos_reminder($new));
            Notification::send($user1, new SlackNotification($new));

            event(new MessageNotification('evening time query executed'));
            Log::info('Working');
        }
        if($night_time->count()!=0){
            $user1 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_primary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();

            $user2 = employee::select('employees.id')->join('attendant_assigns','attendant_assigns.attendant_secondary','=','employees.id')->join('inpatient_prescriptions','attendant_assigns.ward','=','inpatient_prescriptions.ward_id')->first();


            $new = $night_time;
            $user1->notify(new dos_reminder($new));
            $user2->notify(new dos_reminder($new));
            Notification::send($user1, new SlackNotification($new));
            event(new MessageNotification('Night time query executed'));
            Log::info('Working');
        }
    })->everyMinute();
    
}

Here is the corn job command I have added in cPanel

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

It is not executing. Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文