1

I am using ubuntu . i run python script from php function.I want to run the python in background (Asynchronous) . I try following codes. the codes are working but the control is waiting for full python script to completed. After that only moves to next line in php file.

shell_exec("nohup python2.7 /var/www/html/pythonproject/python.py /var/www/html/file 100525 &");

exec("nohup /usr/bin/python2.7 /var/www/html/pythonproject/python.py /var/www/html/file 100525 &");

I Found Solution it is working for me

exec("/usr/bin/python2.7 /var/www/html/pythonproject/python.py /var/www/html/file 100525  > /dev/null 2>/dev/null &")
1
  • exec("/usr/bin/python2.7 /var/www/html/pythonproject/python.py /var/www/html/file 100525 > /dev/null 2>/dev/null &") Commented May 30, 2018 at 7:39

1 Answer 1

2

You should fork() a child process and then wait() for it. In PHP I believe you fork using this: https://secure.php.net/manual/en/function.pcntl-fork.php

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.