Run a php script as a background process in wamp server

后端 未结 6 1331
无人共我
无人共我 2020-12-08 18:14

I have two php scripts that need to be run as continuous back ground processes in WAMP server.

Wamp server is installed in window 7 PC. These scripts are already res

6条回答
  •  渐次进展
    2020-12-08 18:24

    Simply use this function. It works under both OSs (Windows and Linux):

    function execInBackground($cmd){
        if (substr(php_uname(), 0, 7) == "Windows"){ 
            pclose(popen("start /B ". $cmd, "r"));  
        }else{ 
            exec($cmd . " > /dev/null &");   
        } 
    } 
    

    Here is an easy example of how to use the function:

    execInBackground('php feed/handleFeed.php db_name '.$second_param);
    

    In above example, we start script handleFeed.php that is located in folder named "feed" and we pass 2 parameters (database name and some other second parameter).

提交回复
热议问题