PHP exec()作为后台进程(Windows Wampserver环境) [英] PHP exec() as Background Process (Windows Wampserver Environment)

查看:119
本文介绍了PHP exec()作为后台进程(Windows Wampserver环境)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个将触发后台进程的php触发文件. (请参见此问题)

I'm trying to setup a php trigger file that will set off a background process. (see this question)

我正在Windows Wampserver环境中执行此操作.

I'm doing this on a Windows Wampserver environment.

例如,我有一个trigger.php运行exec函数,该函数要求解析和执行我的backgroundProcess.php.

So for example I have trigger.php that runs the exec function that calls for my backgroundProcess.php to be parsed and executed.

但是问题是我的trigger.php文件正在等待exec()命令完成运行,然后再停止运行.后台进程运行大约20到30秒,trigger.php一直等待直到backgroundProcess.php完全完成.

However the problem is that my trigger.php file is waiting for the exec() command to finish running backgroundProcess.php before it stops. The background process runs for about 20-30 seconds, and trigger.php is waiting all that time until backgroundProcess.php has fully finished.

这有意义吗?这是运行exec()命令的trigger.php文件

Is that making sense? Here is the trigger.php file that runs the exec() command

exec('C:\wamp\bin\php\php'.phpversion().'\php.exe -f C:\path\to\backgroundProcess.php > C:\wamp\bin\php\php'.phpversion().'\dev\null &');

基本上,我希望trigger.php只是触发backgroundProcess而不是等待它完成.

Basically, I'm wanting trigger.php to just trigger off the backgroundProcess and not wait around for it to finish.

编辑

使用以下命令解决问题:

Problem solved with the following command:

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:\wamp\bin\php\phpVERSIONNUMBER\php-win.exe -f C:/wamp/www/path/to/backgroundProcess.php", 0, false);

推荐答案

使用以下命令解决问题:

Problem solved with the following command:

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:\wamp\bin\php\phpVERSIONNUMBER\php-win.exe -f C:/wamp/www/path/to/backgroundProcess.php", 0, false);

这篇关于PHP exec()作为后台进程(Windows Wampserver环境)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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