I call a python script from PHP but i run script in background because i don't want to wait after script to finish, so i use > /dev/null 2>/dev/null & with shell_exec.
This is the code where i call:
shell_exec("C:\\Python27\\python C:\\xampp\\htdocs\\testing.py > /dev/null 2>/dev/null &");
in python script i have a simple write file:
fileName = "temp.txt"
target = open(fileName, 'w')
for x in range(1, 59):
target.write("test" + str(x) + " ")
target.close()
When i call script from PHP with shell_exec("C:\\Python27\\python C:\\xampp\\htdocs\\testing.py");
it's working but webpage it's waiting after script to finish and i don't want that, so i called with > /dev/null 2>/dev/null & but now, the code doesn't run.
Any ideas why code doesn't working when i want to run in background?
Thanks!
LE:
Changed /dev/null/ with nul and still no working.
Now i call shell_exec("C:\\Python27\\python C:\\xampp\\htdocs\\testing.py > NUL 2> NUL &"); and it's working but page still wating after script to finish.
nuland not/dev/nullNUL, notnul./dev/nullis a Linux bit bucket, andC:\\...is a Windows path... you cannot mix and match Linux and Windows paths like this.> NUL 2> NUL &is a Linux command (with the Win bit bucket). As I said, you cannot mix and match Linux and Windows stuff like this. Outputting stuff to NUL would just be... > NUL. According to this, background processes are run usingSTART /B [PATH_TO_EXEC]. Do some research before asking more questions.