Note that there are some explanatory texts on larger screens.

plurals
  1. PORun Script in Background Linux Server w/ PHP exec()
    text
    copied!<p>I'm trying to trigger a PHP script to run in the background using the exec() function but I cannot get it to work. I've read countless posts on stack overflow and other forums and tried many variations to no avail.</p> <p><strong>Server Info:</strong></p> <pre><code>Operating System: Linux PHP: 5.2.17 Apache Version: 2.2.23 Home Directory: /home1/username </code></pre> <p>I'm currently using the code:</p> <pre><code>exec("/home1/username/php /home1/username/public_html/myscript.php &gt; /dev/null &amp;"); </code></pre> <p>When I run the above script I get no error_log and no error in my cPanel error log, however the script definitely doesn't execute. When I browse to <a href="http://www.mydomain.com/myscript.php" rel="nofollow">http://www.mydomain.com/myscript.php</a> it runs and e-mails me instantly. Any idea why this isn't working / how I can find out what error is being produced?</p> <p><strong>Update cPanel Process Manager Output</strong> </p> <pre><code>exec("php /home1/username/php /home1/username/public_html/myscript.php &gt; /dev/null &amp;"); </code></pre> <p>Produces:</p> <pre><code>27183 php /home1/username/php /home1/username/public_html/myscript.php 27221 [sh] 27207 php /home1/username/php /home1/username/public_html/myscript.php 27219 php /home1/username/php /home1/username/public_html/myscript.php 27222 php /home1/username/php /home1/username/public_html/myscript.php 27224 php /home1/username/php /home1/username/public_html/myscript.php 27249 sh -c php /home1/username/php /home1/username/public_html/myscript.php &gt; /dev/null &amp; </code></pre> <p>Is that normal? Script appears to hang around for a long time even though it should execute very quickly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload