使用PHP shell_exec在后台运行python脚本
我有一个运行TCP服务器的python脚本,它正在无限期地运行。 此脚本正在“我的终端”的后台工作: 但当我使用PHP shell_exec命令时: shell_exec('sudo python3 TCPServer.py&'))使用PHP shell_exec在后台运行python脚本,php,python,raspberry-pi,Php,Python,Raspberry Pi,我有一个运行TCP服务器的python脚本,它正在无限期地运行。 此脚本正在“我的终端”的后台工作: 但当我使用PHP shell_exec命令时: shell_exec('sudo python3 TCPServer.py&')) 它执行,但永远等待。我希望它在后台运行 要在后台使用shell\u exec运行命令,必须将输出重定向到/dev/null。请参阅 谢谢我在找什么。:) sudo python3 TCPServer.py & shell_exec("python3 TCP
它执行,但永远等待。我希望它在后台运行 要在后台使用
shell\u exec
运行命令,必须将输出重定向到/dev/null。请参阅
谢谢我在找什么。:)
sudo python3 TCPServer.py &
shell_exec("python3 TCPServer.py 2>&1 | tee -a /tmp/mylog 2>/dev/null >/dev/null &");