Php background process in Windows environment
am using Windows 7 and Wamp Server. I have 2 php files trigger.php, background.php. I want to run background.php in the background. I need to call this file from trigger.php.
I tried below methods.
I added this code to trigger.php
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:\wamp\bin\php\php5.3.5\php-win.exe -f C:/wamp/www/background.php", 0, false);
but my background.php is not called.
How can i do this?
any suggestions are appreciated.
+3
source to share
2 answers
i changed the function as below,
$cmd = 'C:\wamp\bin\php\php5.3.5\php.exe C:\wamp\www\email3.php';
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B " . $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
and, its works for me. :)
0
source to share