Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since this is a case where the script is hanging, PHP possibly may not process any additional code that could detect this hang. For this reason, I suggest modifying the script to keep a log. This would allow the main script to let anything outside of it know it is still running, and with some well placed updates it can also help pinpoint where things have gone awry.</p> <p>The logging can be written to a file or database, and should contain at least an indicator of the scripts status, such as a last modified date. If this script is not constantly running, then something should also indicate it is running or has stopped. In the example you gave, the log writing would occur within the while loop at least once, possibly more. It costs time/resources to open the pointers or DB connection, so I recommend logging only what is needed. (Note: If using the text file approach, the file would need to be closed right after each write.)</p> <p>Example:</p> <pre><code>while (1) { log('Running SQL select'); // Do a SQL select log('Results retrieved'); // for any matching rows, do something // (check log) if I have been running for longer than 60 mins, exit } function log($msg) { // Write timestamp, $msg to log } </code></pre> <p>A separate script would need to check the log and report any errors, which could be problematic if it's affected by what's making the main script hang, but I can't think of an alternative.</p> <p>In regards to memory, if you are not already using <a href="http://php.net/manual/en/function.mysql-free-result.php" rel="nofollow">mysql_free_result</a> you should give give it a try.</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