private function executeCommand(AbstractCronjob $cronjob, InputInterface $input, OutputInterface $output)
 {
     $executableFinder = new PhpExecutableFinder();
     if (false === ($php = $executableFinder->find())) {
         throw new \RuntimeException('Unable to find the PHP executable.');
     }
     $builder = new ProcessBuilder();
     $builder->setPrefix($php);
     $builder->setArguments(array($this->container->getParameter('agentsib_crontab.cronjob_console'), 'agentsib:crontab:execute', $cronjob->getId()));
     $builder->setWorkingDirectory(realpath($this->container->getParameter('kernel.root_dir') . '/../'));
     $process = $builder->getProcess();
     //        $process->getOutput();
     $process->setTimeout($cronjob->getExecuteTimeout());
     $process->start();
     return $process;
 }
 public function appendToLog(AbstractCronjob $cronjob, $channel, $str)
 {
     if (!is_dir($this->logPath)) {
         @mkdir($this->logPath);
     }
     if ($cronjob->getLogFile()) {
         $date = new \DateTime();
         $strings = explode(PHP_EOL, $str);
         $log = '';
         foreach ($strings as $s) {
             $log .= sprintf('%s [%s] %s: %s' . PHP_EOL, $date->format('Y-m-d H:i:s'), $cronjob->getId(), $channel, $s);
         }
         @file_put_contents($this->logPath . '/' . $cronjob->getLogFile() . '.log', $log, FILE_APPEND);
     }
 }