public function testStart() { if (file_exists($this->log_file)) { unlink($this->log_file); } $this->crontab->start(time()); $out = file_get_contents($this->log_file); $except = shell_exec("ls /"); $this->assertEquals($out, $except); }
/** * start crontab every minute */ public function crontabCallback(Crontab $crontab, LoopInterface $loop) { $loop->addTimer(60 - time() % 60, function () use($crontab) { $pid = pcntl_fork(); if ($pid > 0) { return; } elseif ($pid == 0) { $crontab->start(time()); exit; } else { $this->logger->error("could not fork"); exit; } }); }