public static function cron() { foreach (eqLogic::byType('virtual') as $eqLogic) { $autorefresh = $eqLogic->getConfiguration('autorefresh'); if ($eqLogic->getIsEnable() == 1 && $autorefresh != '') { try { $c = new Cron\CronExpression($autorefresh, new Cron\FieldFactory()); if ($c->isDue()) { try { foreach ($eqLogic->getCmd('info') as $cmd) { $value = $cmd->execute(); if ($cmd->execCmd() != $cmd->formatValue($value)) { $cmd->setCollectDate(''); $cmd->event($value); } } } catch (Exception $exc) { log::add('virtual', 'error', __('Erreur pour ', __FILE__) . $eqLogic->getHumanName() . ' : ' . $exc->getMessage()); } } } catch (Exception $exc) { log::add('virtual', 'error', __('Expression cron non valide pour ', __FILE__) . $eqLogic->getHumanName() . ' : ' . $autorefresh); } } } }
public static function cron() { foreach (self::byType('networks') as $networks) { $autorefresh = $networks->getConfiguration('autorefresh'); if ($networks->getIsEnable() == 1 && $autorefresh != '') { try { $c = new Cron\CronExpression($autorefresh, new Cron\FieldFactory()); if ($c->isDue()) { try { $networks->ping(); } catch (Exception $exc) { log::add('networks', 'error', __('Erreur pour ', __FILE__) . $networks->getHumanName() . ' : ' . $exc->getMessage()); } } } catch (Exception $exc) { log::add('networks', 'error', __('Expression cron non valide pour ', __FILE__) . $networks->getHumanName() . ' : ' . $autorefresh); } } } }
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(); } } } } } }
foreach ($argv as $arg) { $argList = explode('=', $arg); if (isset($argList[0]) && isset($argList[1])) { $_GET[$argList[0]] = $argList[1]; } } } try { require_once dirname(__FILE__) . '/../core/php/core.inc.php'; $crons = cron::all(); if (is_array($crons)) { if (class_exists('Cron\\CronExpression')) { foreach ($crons as $cron) { $c = new Cron\CronExpression($cron->getSchedule(), new Cron\FieldFactory()); try { if (!$c->isDue()) { $c->getNextRunDate(); } } catch (Exception $ex) { echo "Suppression de : " . $cron->getName() . ' car pas de lancement prévu'; $cron->remove(); } } } } $cron = cron::byClassAndFunction('jeedom', 'persist'); if (is_object($cron)) { $cron->remove(); } $cron = cron::byClassAndFunction('plugin', 'cron'); if (is_object($cron)) {
public static function cron() { if (!self::isStarted()) { config::save('enableScenario', 1); config::save('enableCron', 1); $cache = cache::byKey('jeedom::usbMapping'); $cache->remove(); foreach (cron::all() as $cron) { if ($cron->running() && $cron->getClass() != 'jeedom' && $cron->getFunction() != 'cron') { try { $cron->halt(); } catch (Exception $e) { } } } try { jeedom::start(); } catch (Exception $e) { } try { plugin::start(); } catch (Exception $e) { } touch('/tmp/jeedom_start'); self::event('start'); log::add('core', 'info', 'Démarrage de Jeedom OK'); } self::isDateOk(); try { $c = new Cron\CronExpression(config::byKey('update::check'), new Cron\FieldFactory()); if ($c->isDue()) { $lastCheck = strtotime(config::byKey('update::lastCheck')); if (strtotime('now') - $lastCheck > 3600) { if (config::byKey('update::auto') == 1) { update::checkAllUpdate(); jeedom::update('', 0); } else { config::save('update::check', rand(1, 59) . ' ' . rand(6, 7) . ' * * *'); update::checkAllUpdate(); $updates = update::byStatus('update'); if (count($updates) > 0) { $toUpdate = ''; foreach ($updates as $update) { $toUpdate .= $update->getLogicalId() . ','; } message::add('update', __('De nouvelles mises à jour sont disponibles : ', __FILE__) . trim($toUpdate, ','), '', 'newUpdate'); } } } } $c = new Cron\CronExpression('35 00 * * 0', new Cron\FieldFactory()); if ($c->isDue()) { cache::clean(); DB::optimize(); } $c = new Cron\CronExpression('02 02 * * *', new Cron\FieldFactory()); if ($c->isDue()) { try { log::chunk(); cron::clean(); } catch (Exception $e) { log::add('log', 'error', $e->getMessage()); } } $c = new Cron\CronExpression('21 23 * * *', new Cron\FieldFactory()); if ($c->isDue()) { try { scenario::cleanTable(); user::cleanOutdatedUser(); scenario::consystencyCheck(); } catch (Exception $e) { log::add('scenario', 'error', $e->getMessage()); } } } catch (Exception $e) { } }
public function isDue() { $last = strtotime($this->getLastLaunch()); $now = time(); $now = $now - $now % 60; $last = $last - $last % 60; if ($now == $last) { return false; } if (is_array($this->getSchedule())) { foreach ($this->getSchedule() as $schedule) { try { $c = new Cron\CronExpression($schedule, new Cron\FieldFactory()); try { if ($c->isDue()) { return true; } } catch (Exception $e) { } try { $prev = $c->getPreviousRunDate()->getTimestamp(); } catch (Exception $e) { return false; } $lastCheck = strtotime($this->getLastLaunch()); $diff = abs((strtotime('now') - $prev) / 60); if ($lastCheck <= $prev && $diff <= config::byKey('maxCatchAllow') || config::byKey('maxCatchAllow') == -1) { return true; } } catch (Exception $e) { } } } else { try { $c = new Cron\CronExpression($this->getSchedule(), new Cron\FieldFactory()); try { if ($c->isDue()) { return true; } } catch (Exception $e) { } try { $prev = $c->getPreviousRunDate()->getTimestamp(); } catch (Exception $e) { return false; } $lastCheck = strtotime($this->getLastLaunch()); $diff = abs((strtotime('now') - $prev) / 60); if ($lastCheck <= $prev && $diff <= config::byKey('maxCatchAllow') || config::byKey('maxCatchAllow') == -1) { return true; } } catch (Exception $exc) { } } return false; }
public static function cron() { //Rafraichissement des valeurs des modules foreach (eqLogic::byType('zwave') as $eqLogic) { $scheduler = $eqLogic->getConfiguration('refreshDelay', ''); if ($scheduler != '') { try { $c = new Cron\CronExpression($scheduler, new Cron\FieldFactory()); if ($c->isDue()) { try { foreach ($eqLogic->getCmd() as $cmd) { $cmd->forceUpdate(); } } catch (Exception $exc) { log::add('zwave', 'error', 'Erreur pour ' . $eqLogic->getHumanName() . ' : ' . $exc->getMessage()); } } } catch (Exception $exc) { log::add('zwave', 'error', 'Expression cron non valide pour ' . $eqLogic->getHumanName() . ' : ' . $scheduler); } } } //Verification des piles une fois par jour if (date('H:i') == '00:00') { foreach (zwave::byType('zwave') as $eqLogic) { $http = new com_http(self::makeBaseUrl() . '/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . '].instances[0].commandClasses[0x80].Get()'); try { $http->exec(); } catch (Exception $exc) { } $info = $eqLogic->getInfo(); if (isset($info['state']) && $info['state'] == 'Réveillé') { continue; } if (isset($info['battery']) && $info['battery'] !== '') { $eqLogic->batteryStatus($info['battery']['value']); } } } }
/** * Check if it's time to launch cron * @return boolean */ public function isDue() { //check if already sent on that minute $last = strtotime($this->getLastRun()); $now = time(); $now = $now - $now % 60; $last = $last - $last % 60; if ($now == $last) { return false; } try { $c = new Cron\CronExpression($this->getSchedule(), new Cron\FieldFactory()); try { if ($c->isDue()) { return true; } } catch (Exception $e) { } try { $prev = $c->getPreviousRunDate()->getTimestamp(); } catch (Exception $e) { return false; } $diff = abs((strtotime('now') - $prev) / 60); if (strtotime($this->getLastRun()) < $prev && ($diff <= config::byKey('maxCatchAllow') || config::byKey('maxCatchAllow') == -1)) { return true; } } catch (Exception $e) { log::add('cron', 'debug', 'Error on isDue : ' . $e->getMessage() . ', cron : ' . $this->getSchedule()); } return false; }
public static function cron() { //Rafraichissement des valeurs des modules foreach (eqLogic::byType('zwave') as $eqLogic) { if ($eqLogic->getIsEnable() == 1) { $scheduler = $eqLogic->getConfiguration('refreshDelay', ''); if ($scheduler != '') { try { $c = new Cron\CronExpression($scheduler, new Cron\FieldFactory()); if ($c->isDue()) { try { foreach ($eqLogic->getCmd('info') as $cmd) { if ($cmd->getConfiguration('doNotAutoRefresh', 0) == 0) { $cmd->forceUpdate(); } } } catch (Exception $exc) { log::add('zwave', 'error', __('Erreur pour ', __FILE__) . $eqLogic->getHumanName() . ' : ' . $exc->getMessage()); } } } catch (Exception $exc) { log::add('zwave', 'error', __('Expression cron non valide pour ', __FILE__) . $eqLogic->getHumanName() . ' : ' . $scheduler); } } } } if (config::byKey('jeeNetwork::mode') == 'slave') { $cron = cron::byClassAndFunction('zwave', 'pull'); if (is_object($cron)) { $cron->remove(); } } }