getCommandList(); $commands = []; foreach ($schedule as $line) { $line = trim($line); if ($line === '') { continue; } $data = $this->parseCommandLine($line); if ($this->processSchedule($now, $data)) { $commands[] = $data['command']; } } return $commands; } protected function getCommandList(): array { if (!file_exists($this->filename)) { return []; } return explode("\n", file_get_contents($this->filename)); } protected function parseCommandLine(string $line): array { $regex = '/^(?(\d{1,2}|\*|\*\/\d{1,2})?) (?(\d{1,2}|\*|\*\/\d{1,2})?) (?(\d{1,2}|\*|\*\/\d{1,2})?) (?(\d{1,2}|\*|\*\/\d{1,2})?) (?(\d{1,2}|\*|\*\/\d{1,2})?) (?.*)$/'; preg_match_all($regex, $line, $matches); return [ 'minutes' => $matches['minutes'][0], 'hours' => $matches['hours'][0], 'day_month' => $matches['day_month'][0], 'month' => $matches['month'][0], 'day_week' => $matches['day_week'][0], 'command' => trim(str_replace(['/code/bin/incoviba', '>> /logs/commands 2>&1'], '', $matches['command'][0])), ]; } protected function processSchedule(DateTimeInterface $now, array $schedule): bool { $cronLine = "{$schedule['minutes']} {$schedule['hours']} {$schedule['day_month']} {$schedule['month']} {$schedule['day_week']}"; $cron = new CronExpression($cronLine); return $cron->isDue($now); } }