문제

I have a QNAP box, that runs a flavor of linux and I am having problems getting the PID of a process using a php script. What I have so far:

$command = "PATH=$PATH:/share/MD0_DATA/.qpkg/Optware/bin: nohup /opt/bin/plowdown -o /share/MD0_DATA/Qdownload/plowshare http://www.megaupload.com/?d=m7duotr1 2> /share/MD0_DATA/Qdownload/plowshare/outputeeds.txt > /dev/null &";
exec($command, $out);
$result = $out[0];
echo $result;

If I run the command through PUTTY, I get:

[~] # nohup /opt/bin/plowdown -o /share/MD0_DATA/Qdownload/plowshare http://www.megaupload.com/?d=m7duotr1 2> /share/MD0_DATA/Qdownload/plowshare/outputteeds.txt > /dev/null &
22526

What am I doing wrong?

Thanks,

Cristian.

도움이 되었습니까?

해결책

The shell does not normally print the PID of a process it starts in background, unless it's interactive. Otherwise, you would get tons of output during bootup just from the PIDs of all the processes that get started.

So you need to make the shell print the PID. Do

 exec("(PATH=$PATH:/share/MD0_DATA/.qpkg/Optware/bin: " . 
      "nohup /opt/bin/plowdown -o /share/MD0_DATA/Qdownload/plowshare " .
      "http://www.megaupload.com/?d=m7duotr1 2> " . 
      "/share/MD0_DATA/Qdownload/plowshare/outputeeds.txt > /dev/null &);" . 
      "echo $$;", $out);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top