Reputation: 33
I have a python script that runs a TCP server and is running indefinitely. This script is working on background in my terminal:
sudo python3 TCPServer.py &
But when I use PHP shell_exec command:
shell_exec('sudo python3 TCPServer.py &')
It executes but waits forever. I want it to run on background.
Upvotes: 3
Views: 1259
Reputation: 28524
To run a command in background with shell_exec
, the output must be redirected to /dev/null. Refer the php nanual notes.
shell_exec("python3 TCPServer.py 2>&1 | tee -a /tmp/mylog 2>/dev/null >/dev/null &");
Upvotes: 1