title: PHP - Parallel processing
body: <p>I'm working on a web application that needs to send a lot of HTTP requests and update the table, this will block the PHP from executing. So I though I might have to write a separate PHP script and run it via my main application. I tried Exec but still the program waits until the script is executed.</p>
  
  <pre><code>exec('php do_job.php');
  </code></pre>
  
  <p>I even tried redirecting the output to a file as PHP.Net suggests:</p>
  
  <blockquote>
    <p>Note: If a program is started with this function, in order for it to
    continue running in the background, the output of the program must be
    redirected to a file or another output stream. Failing to do so will
    cause PHP to hang until the execution of the program ends.</p>
  </blockquote>
  
  <pre><code>$result = exec('php do_job.php &gt; output.txt &amp;',$output);
  </code></pre>
  
  <p>But still no success ... Further down the same page I came accross this:</p>
  
  <pre><code>$command = 'php do_job.php';
  $shell = new COM("WScript.Shell");
  $shell-&gt;run($command, 0, false);
  </code></pre>
  
  <p>Still no sucess ... Lastly I tried:</p>
  
  <pre><code>pclose(popen("start /B ". $command, "r"));
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>I'm developing my app on localhost (XAMPP - Windows), later I'll be releasing it on a Linux host. My last resort would be to run the script via CRON jobs. Is this the only way? </p>