コード例 #1
0
 public static function cronHourly()
 {
     foreach (self::byType('weather') as $weather) {
         if ($weather->getIsEnable() == 1) {
             $cron = cron::byClassAndFunction('weather', 'pull', array('weather_id' => intval($weather->getId())));
             if (!is_object($cron)) {
                 $weather->reschedule();
             } else {
                 try {
                     $c = new Cron\CronExpression($cron->getSchedule(), new Cron\FieldFactory());
                     if (!$c->isDue()) {
                         $c->getNextRunDate();
                     }
                 } catch (Exception $ex) {
                     if ($c->getPreviousRunDate()->getTimestamp() < strtotime('now') - 300) {
                         $weather->reschedule();
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: 1.107.0.php プロジェクト: GaelGRIFFON/core
<?php

$crons = cron::all();
foreach ($crons as $cron) {
    $c = new Cron\CronExpression($cron->getSchedule(), new Cron\FieldFactory());
    try {
        $c->getNextRunDate();
    } catch (Exception $ex) {
        $cron->remove();
    }
}
コード例 #3
0
ファイル: scenario.class.php プロジェクト: GaelGRIFFON/core
 public function calculateScheduleDate()
 {
     $calculatedDate = array('prevDate' => '', 'nextDate' => '');
     if (is_array($this->getSchedule())) {
         $calculatedDate_tmp = array('prevDate' => '', 'nextDate' => '');
         foreach ($this->getSchedule() as $schedule) {
             try {
                 $c = new Cron\CronExpression($schedule, new Cron\FieldFactory());
                 $calculatedDate_tmp['prevDate'] = $c->getPreviousRunDate()->format('Y-m-d H:i:s');
                 $calculatedDate_tmp['nextDate'] = $c->getNextRunDate()->format('Y-m-d H:i:s');
             } catch (Exception $exc) {
                 //echo $exc->getTraceAsString();
             }
             if ($calculatedDate['prevDate'] == '' || strtotime($calculatedDate['prevDate']) < strtotime($calculatedDate_tmp['prevDate'])) {
                 $calculatedDate['prevDate'] = $calculatedDate_tmp['prevDate'];
             }
             if ($calculatedDate['nextDate'] == '' || strtotime($calculatedDate['nextDate']) > strtotime($calculatedDate_tmp['nextDate'])) {
                 $calculatedDate['nextDate'] = $calculatedDate_tmp['nextDate'];
             }
         }
     } else {
         try {
             $c = new Cron\CronExpression($this->getSchedule(), new Cron\FieldFactory());
             $calculatedDate['prevDate'] = $c->getPreviousRunDate()->format('Y-m-d H:i:s');
             $calculatedDate['nextDate'] = $c->getNextRunDate()->format('Y-m-d H:i:s');
         } catch (Exception $exc) {
             //echo $exc->getTraceAsString();
         }
     }
     return $calculatedDate;
 }
コード例 #4
0
ファイル: cron.class.php プロジェクト: saez0pub/core
 public static function clean()
 {
     $crons = self::all();
     foreach ($crons as $cron) {
         $c = new Cron\CronExpression($cron->getSchedule(), new Cron\FieldFactory());
         try {
             if (!$c->isDue()) {
                 $c->getNextRunDate();
             }
         } catch (Exception $ex) {
             $cron->remove();
         }
     }
 }