简体   繁体   English

如何从php-web页面centos服务器在后台运行exec()命令

[英]How can I run exec() command in background from php-web page centos server

I prepared my setup on ubuntu and everything is working fine on my local server(ie ubuntu as weel as mint). 我在ubuntu上准备了安装程序,并且在我的本地服务器上一切正常(即ubuntu就像薄荷一样)。

But when i transferred my files to centos server .....i am not able to execute exec() or system command in background.( i changed the permission of program too) 但是当我将文件传输到centos服务器时.....我无法在后台执行exec()或系统命令。(我也更改了程序的权限)

I used following command in ubuntu: 我在ubuntu中使用了以下命令:

$pid=system("./programme.exe {$arg1} {$arg2} {$arg3}>output.txt & echo $!");

Could anyone explain why not this is not working on centos(in background)....... but system("./programme.exe {$arg1} {$arg2} {$arg3}) ; works fine............ 任何人都可以解释为什么它不能在centos上工作(在后台).......但是system(“ ./ programme.exe {$ arg1} {$ arg2} {$ arg3});可以正常工作... ......

I'm not sure, but it could be because of system runs a program and redirects the output back. 我不确定,但这可能是因为系统运行了一个程序并将输出重定向回去。 In your command, you redirecting aswell, so maybe php is waiting for the output. 在您的命令中,您还要重定向,因此php正在等待输出。 Try using exec instead of system. 尝试使用exec而不是system。

exec($cmd . " > /dev/null &");   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM