system("echo \"{$now} Lock file found in {$lockfile}. Skipping.\" >> {$logfile}"); return; } $cp = new CronParser($schedule); // if 1) job is enabled // 2) and, we are on specified host // 3) and, job is scheduled to run // then, start execution if ($enabled && strcasecmp($runonhost, $thishost) == 0 && $cp->hasRunInTheLast(self::RUN_INTERVAL)) { // create lock file touch($lockfile); // start execution $cmd = file_exists("{$job}.php") ? "php {$job}.php" : "{$job}.sh"; if (!$this->_windows) { $useSudo = "sudo -u {$runas}"; } exec("{$useSudo} {$cmd} 1>> {$logfile} 2>&1", $dummy, $retval); // remove lock file unlink($lockfile); // mail log file if error if ($retval !== 0) { $this->_maillog(); } } // clean up any old logs exec("find logs -mtime +{$keep} | xargs rm -f"); } } $slave = new Slave(); $slave->work($argv[1]);