Laravel:如何为多台机器运行一个 cron 作业?

问题描述 投票:0回答:0

我有多个手指机器。我想同时为多个手指机器运行多个计划。如何为它运行多个计划?下面的代码是为一台手指机运行的。

protected function schedule(Schedule $schedule)
{
    $pagi = WaktuMesin::select('pagi')->first();
    $tarik_pagi = explode('-', $pagi['pagi']);
    $tarik_pagi = $tarik_pagi[1];
    $tarik_pagi_kehadiran = date('H:i', strtotime($tarik_pagi. ' +3 minutes'));
   
    $siang = WaktuMesin::select('siang')->first();
    $tarik_siang = explode('-', $siang['siang']);
    $tarik_siang = $tarik_siang[1];
    $tarik_siang_kehadiran = date('H:i', strtotime($tarik_siang. ' +3 minutes'));

    $sore = WaktuMesin::select('sore')->first();
    $tarik_sore = explode('-', $sore['sore']);
    $tarik_sore = $tarik_sore[1];
    $tarik_sore_kehadiran = date('H:i', strtotime($tarik_sore. ' +3 minutes'));
    
    $schedule->command('tarik:absen')->everyMinute()->timezone('Asia/Jakarta');
    $schedule->command('send:wa')->everyMinute()->timezone('Asia/Jakarta');
    $schedule->command('tarik:pagi')->dailyAt($tarik_pagi_kehadiran)->timezone('Asia/Jakarta');
    $schedule->command('tarik:siang')->dailyAt($tarik_siang_kehadiran)->timezone('Asia/Jakarta');
    $schedule->command('tarik:sore')->dailyAt($tarik_sore_kehadiran)->timezone('Asia/Jakarta');
}
php laravel cron schedule cron-task
© www.soinside.com 2019 - 2024. All rights reserved.