0

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.

1

1 Answer 1

2

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 &');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.