我试图在后台执行一个python脚本,并从一个php脚本中获取一个pid,该脚本通过单击按钮来调用。这里的问题是PID不存在,python脚本的任务没有完成。我不知道发生了什么事。我已经用终端测试了python脚本,它的工作方式很有魅力。在
echo 'Starting the mapping process';
echo exec('python frist_script.py > /dev/null 2>&1 & echo $!');
//echo exec('ls > /dev/null 2>&1 & echo $!;');
?>
python脚本只执行一个ls并将输出写入一个文件。python脚本的代码如下。在
^{pr2}$
注意:这不是最终的脚本,而是一个测试脚本,用于确认python脚本调用是否正常工作。在
非常感谢任何帮助。在
谢谢
PS:ls -al的输出-rw-rw-r-- 1 acs www-data 262 May 18 16:31 execute.php
-rwxr-xr-x 1 www-data www-data 147 May 18 16:17 frist_script.py
我也试过shell_exec()
编辑:我试着运行一个简单的shell脚本,但是没有得到很好的执行,但是shell命令可以工作。在
更新:python脚本或shell脚本在从终端php execute.php执行时工作,但在从web服务器运行时不工作。在