문제

Right, I am calling a Python script in a PHP script. This PHP script needs to continue after the Python script has been called.

I have tried all of the following, yet PHP insists on waiting until the script has responded.

All tried:-

system('nohup python /home/process/script.py -i '.escapeshellarg($location).' &');
system('nohup python /home/process/script.py -i '.escapeshellarg($location).' 2>&1 &');
system('nohup python /home/process/script.py -i '.escapeshellarg($location).' < /dev/null 2>&1 &');
exec('nohup python /home/process/script.py -i '.escapeshellarg($location).' &');
exec('nohup python /home/process/script.py -i '.escapeshellarg($location).' 2>&1 &');
exec('nohup python /home/process/script.py -i '.escapeshellarg($location).' < /dev/null 2>&1 &');

Also tried with passthru and without nohup.

Any help greatly appreciated.

도움이 되었습니까?

해결책

Quoting the exec doc:

If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

You should try this instead:

exec('nohup python /home/process/script.py -i '.escapeshellarg($location).' &>/dev/null &');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top