php background process in windows environment

后端 未结 2 1753
无人共我
无人共我 2021-01-03 08:22

am using windows-7 OS and wamp server. i have 2 php files trigger.php,background.php. i want to run background.php in background .i have to call this file from trigger.php

相关标签:
2条回答
  • 2021-01-03 08:56
    function execInBackground($cmd) { 
        if (substr(php_uname(), 0, 7) == "Windows"){ 
            pclose(popen("start /B ". $cmd, "r"));  
        } 
        else { 
            exec($cmd . " > /dev/null &");   
        } 
    }
    

    in this case your $cmd would be "php C:/wamp/www/path/to/background.php"

    0 讨论(0)
  • 2021-01-03 09:05

    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 讨论(0)
提交回复
热议问题