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;
}