在PHP中执行exec()或system(),不等待输出 [英] Executing an exec() or system() in PHP and do not wait for output

查看:1529
本文介绍了在PHP中执行exec()或system(),不等待输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在eider exec()或system()从PHP脚本中触发shell命令,但它是一个任务需要一段时间来完成,是有一种方法来触发它,并继续运行PHP页面加载没有延迟?



编辑:我在CentOS 6,PHP 5.3

解决方案

取决于您使用的操作系统。



对于linux:

  pclose(popen(php somefile.php&,r)); 

注意最后的amperstand(非常重要)。



对于windows:

  pclose(popen(start php.exe somefile.php,r) ); 

这里的 start 关键字很重要。 / p>

希望这有助于。


I want to trigger a shell command in eider exec() or system() from PHP script but it is a task that take a while to complete, is there a way to trigger it and continue running the PHP page load without delay?

Edit: I am on CentOS 6, PHP 5.3

解决方案

Depends on the OS you are using.

For linux:

pclose(popen("php somefile.php &","r"));

notice the amperstand at the end (very important).

For windows:

pclose(popen("start php.exe somefile.php","r"));

here the start keyword is important.

Hope this helps.

这篇关于在PHP中执行exec()或system(),不等待输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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