Bizarre issue running PHP background process
<p>I am attempting to run a background process from within a PHP script. I have successfully used this method elsewhere in production environments with no issues. The basic rundown is as follows:</p>

<pre><code>file_put_contents($batch_file, "#!/bin/bash\ncd " . dirname(__FILE__) . "\nphp thescript.php some params\nrm \$0");
chmod($batch_file, 0750);
shell_exec($batch_file . " &gt; /dev/null 2&gt;/dev/null &amp;");
</code></pre>

<p>This method allows the calling script to terminate while $batch_file does it's thing. It's working fine in my dev environment, but on my host (bluehost), the background process simply runs the calling script again AS THOUGH IT WAS THE SAME REQUEST from the browser (causing an endless loop).</p>

<p>Let me illustrate: </p>

<p>The user makes a request for <a href="http://example.com/frontend.php" rel="nofollow">http://example.com/frontend.php</a></p>

<p>frontend.php runs the background task "php backend.php with some params", but the output of that background task is the same as what the user sees when visiting <a href="http://example.com/frontend.php" rel="nofollow">http://example.com/frontend.php</a>. In fact, I can call "php inexistant_file.php" and the output is the same.</p>

<p>If I inspect $_SERVER, it appears to not change, even though I'm calling a DIFFERENT script from a different interface (CLI vs via apache) and passing command-line parameters.</p>

<p>I suspect a weird caching bug/issue, but have disabled w3tc (it's a wordpress site) with no success. </p>

<p>Any insight?</p>
