title('Watch'); $period = new DateInterval($this->period); $current = new DateTimeImmutable(); $io->info('Starting'); while(true) { $now = new DateTimeImmutable(); if ($now->diff($current) === $period) { $io->info('Running Update'); $this->runUpdate(); $current = $now; } $wait = (new DateTimeImmutable((new DateTimeImmutable())->format('Y-m-d H:i:0')))->add(new DateInterval('PT1M')); time_sleep_until($wait->getTimestamp()); } return Command::SUCCESS; } protected function runUpdate(): void { $command = "{$this->command} update"; $this->logger->info("Running '{$command}'"); shell_exec($command); } }