庆典调用PHP的了shell_exec - 慢 [英] Calling bash with PHP's shell_exec -- slow

查看:340
本文介绍了庆典调用PHP的了shell_exec - 慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP的功能了shell_exec打电话给我的服务器上的bash脚本。

I'm using PHP's shell_exec function to call a bash script on my server.

shell_exec("bash -x /tesladata/isetools/0-extractbytickerforweb.bash $ticker $isedate > /t24alv2/iseoutput/$ticker-$isedate-$thistime.log &");

现在,我previously已经从一个C​​GI脚本运行命令(bash的-x ...),它是要快得多(瞬间)。现在需要的脚本来运行一个痛苦而缓慢的时间(> 10秒)和结果页面进行渲染。

Now, I previously had the command running from a CGI script ("bash -x...") and it was much faster (instantaneous). Now it takes a painfully slow time for the script to run (> 10sec) and for the resulting page to render.

任何想法,为什么这是如此之慢?我还是想从运行PHP和CGI不是在bash脚本,因为我的整个网站被转换到PHP。也许另外一个功能更适合?任何想法将AP preciated。

Any ideas why this is so slow? I'd still like to run the bash script from PHP and not CGI, since my entire site is being converted to PHP. Perhaps another function is more suitable? Any ideas would be appreciated.

推荐答案

您可以看看PHP的的 EXEC 系统功能,我真的不明白了一个道理,为什么他们会加快脚本的执行,值得一试,虽然。我是pretty确保它与阿帕奇(假设你使用Apache),不是PHP这个结论是的这个bug线程

You can take a look at PHP's exec and system functions, however I don't really see a reason why they would speed up the execution of the script, worth a try though. I'm pretty sure it is an issue with apache (assuming you're using apache), not PHP the source of this conclusion being this bug thread.

此外,你真的应该非常小心使用公共网站上这些命令。利用 escapeshellarg 并的 escapeshellcmd

Also you really should be extremely careful of using these commands on a public website. Make use of escapeshellarg and escapeshellcmd.

这篇关于庆典调用PHP的了shell_exec - 慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆