public function __construct()
{
// parsing cron file
$process = new Process('crontab -l');
$process->run();
$lines = array_filter(explode(PHP_EOL, $process->getOutput()), function ($line) {
return '' != trim($line);
});
foreach ($lines as $lineNumber => $line) {
// if line is nt a comment, convert it to a cron
if (strpos($line, '#suspended: ', 0) === 0 || 0 !== strpos($line, '#', 0)) {
try {
$line = Cron::parse($line);
} catch (\Exception $e) {
$process->addErrorOutput('CronManager was unable to parse crontab at line ' . $lineNumber);
}
}
$this->lines['l' . $lineNumber] = $line;
}
$this->error = $process->getErrorOutput();
}