Ejemplo n.º 1
0
 /**
  * 백그라운드로 시스템파일 처리
  * @param bool $blockRedundancy 중복실행 불가 Default:true, 기존 명령실행이 종료되지 않았으면 중복실행불가
  * @return bool
  */
 public function bg($cmd, $blockRedundancy = true)
 {
     $this->setPidFilePath($cmd);
     if ($this->isRunning() && $blockRedundancy) {
         return false;
     } else {
         $cmdFile = $this->cmdFile . " " . implode(' ', $this->params);
         $return = exec("whereis php", $result);
         //            $return = "php: /usr/bin/php /etc/php.d /etc/php.ini /usr/lib64/php /usr/include/php /usr/local/php /usr/share/php /usr/share/man/man1/php.1.gz";
         $whereIsPhpList = explode(' ', str_replace("php:", "", $return));
         $phpScriptFile = '';
         foreach ($whereIsPhpList as $phpFile) {
             if (is_file($phpFile)) {
                 $phpScriptFile = $phpFile;
                 break;
             }
         }
         $result = exec(sprintf($phpScriptFile . ' "' . Directory::html() . '/index.php"' . " %s >> \"%s\" 2>&1 & echo \$! > \"%s\"", 'http://' . Configure::site('host') . '/' . $cmd, $this->logFile, $this->pidFile));
         return true;
     }
 }