Exemple #1
0
        $cron->save();
        $logicalId = config::genKey();
        if ($e->getCode() != 0) {
            $logicalId = $cron->getName() . '::' . $e->getCode();
        }
        echo '[Erreur] ' . $cron->getName() . ' : ' . print_r($e, true);
        log::add('cron', 'error', __('Erreur sur ', __FILE__) . $cron->getName() . ' : ' . print_r($e, true), $logicalId);
    }
} else {
    if (cron::jeeCronRun()) {
        die;
    }
    $sleepTime = config::byKey('cronSleepTime');
    $started = jeedom::isStarted();
    set_time_limit(59);
    cron::setPidFile();
    while (true) {
        if (config::byKey('enableCron', 'core', 1, true) == 0) {
            die(__('Tous les crons sont actuellement désactivés', __FILE__));
        }
        foreach (cron::all() as $cron) {
            try {
                if (!$started && $cron->getClass() != 'jeedom' && $cron->getFunction() != 'cron') {
                    continue;
                }
                if (!$cron->refresh()) {
                    continue;
                }
                $duration = strtotime('now') - strtotime($cron->getLastRun());
                if ($cron->getEnable() == 1 && $cron->getState() != 'run' && $cron->getState() != 'starting' && $cron->getState() != 'stoping') {
                    if ($cron->getDeamon() == 0) {