Hi all,
I am very new to php,I have problem for running php script in backround.My issue is I have a .php (script1.php) file that should run in backround when i click the button in another php (script2.php) file.

Am using Windows xp
Php version 5.3.8
Apache server.

I googled and found like this..

<?php
$cmd="C:\wamp\www\Phpscript\script1.php";

pclose(popen("start /B ".$cmd, 'r'));
?>
but it is not helpful to me..Kindly suggest me any other way..
Thnaks

    $WshShell = new COM("WScript.Shell");
    $oExec = $WshShell->Run("cmd /C dir /S %windir%", 0, false);
    
      5 months later

      Hi,I have used to exec to run the php script in backround..But it not seems to be run in backround..

      echo "successfully loaded";
      exec("php D:/wamp/www/Test_krish/Email.php $List_name $C_name $c_id $L_No $path1 $path2 >outputVR.txt", $output);
      The echo statemnet get displayed only after exec statement gets run..

      Then i tried this

      system("php D:/wamp/www/Test_krish/Email.php $List_name $C_name $c_id $L_No $path1 $path2 > /dev/null &");

      This is not working since am using windows xp...

      How to make this to run in windows

      Please help

      Thanks in Advance
      Ajarwe

        Ajarwe;10996456 wrote:

        <?php
        $cmd="C:\wamp\www\Phpscript\script1.php";

        pclose(popen("start /B ".$cmd, 'r'));
        ?>
        but it is not helpful to me..Kindly suggest me any other way..
        Thnaks

        How about:

        <?php
        $cmd="c:\path\to\php.exe C:\wamp\www\Phpscript\script1.php";  // PHP is an executable ... right?
        
        pclose(popen("start /B ".$cmd, 'r'));
        ?>

          Warning: especially when using double quoted string literals, beware the backslashes.

            I've always run my PHP scripts in the background using Scheduled Tasks. Those were scripts that needed to be run on a regular basis at a specific time, though.

              Write a Reply...