Pimcore\Tool\Console::execInBackgroundUnix PHP Method

execInBackgroundUnix() protected static method

protected static execInBackgroundUnix ( string $cmd, string $outputFile ) : integer
$cmd string
$outputFile string
return integer
    protected static function execInBackgroundUnix($cmd, $outputFile)
    {
        if (!$outputFile) {
            $outputFile = "/dev/null";
        }
        $nice = (string) self::getExecutable("nice");
        if ($nice) {
            $nice .= " -n 19 ";
        }
        $nohup = (string) self::getExecutable("nohup");
        if ($nohup) {
            $nohup .= " ";
        }
        $commandWrapped = $nohup . $nice . $cmd . " > " . $outputFile . " 2>&1 & echo \$!";
        Logger::debug("Executing command `" . $commandWrapped . "ยด on the current shell in background");
        $pid = shell_exec($commandWrapped);
        Logger::debug("Process started with PID " . $pid);
        return $pid;
    }