Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP shell_exec在后台运行python脚本_Php_Python_Raspberry Pi - Fatal编程技术网

使用PHP shell_exec在后台运行python脚本

使用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

我有一个运行TCP服务器的python脚本,它正在无限期地运行。 此脚本正在“我的终端”的后台工作:

但当我使用PHP shell_exec命令时:

shell_exec('sudo python3 TCPServer.py&'))


它执行,但永远等待。我希望它在后台运行

要在后台使用
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 &");