PO6OT2015-09-25 23:28:50
PO6OT, 2015-09-25 23:28:50

After 60 minutes of recursion, the script stopped. How to prevent?

Test on a dedicated server:
60 minutes of work
0 errors
Test on a hosting:
36 minutes of work
1 error 508 Resource Limit Exceeded
Checking and collecting statistics is done by writing output and output time to the log and constantly reading these logs by JavaScript.
How to prevent the script from stopping (no set_time_limits work on the hosting)?
The recursion itself occurs by pinging itself (self-call).
Sometimes something happens and the ping doesn't work. This is where the recursion stops.
Ignore the 508 error. It's just for statistics.
At what after error 508 the script all the same continues to work. Magic =)

    exit; //защита от двойного запуска
    file_put_contents('./date', date('His'));
function ping($action){
    $http=fsockopen($h, 80, $e1, $e2, 1);
    'GET /'.$action.' HTTP/1.1'."\r\n".
    'Accept: */*'."\r\n".
    'Host: '.$h."\r\n\r\n"
    ping('core.php'); //запуск исполнительной программы
    ping('daemon.php'); //перезапуск текущей программы

Answer the question

In order to leave comments, you need to log in

5 answer(s)
Phizio, 2015-09-26

30-40 minute PHPs are unstable. You are most likely experiencing memory leaks.
Yes, it would be more logical to make every minute or every five minutes cron - with each new call, the memory will be cleared. In addition, you have protection against calling 2 processes at the same time. Slightly finish so that one process ends another, and it will work fine (for years;)

Denis, 2015-09-26

The wrong time for testing was chosen.
How much is 000100 - 235800?
Certainly less than three. And because of this, your "pseudo-protection" will skip itself, forcing the date to be written to the file.
And the next iteration will get the difference in the script's work in 2 seconds, then in one ...
Here you have a memory leak.

Alexander Taratin, 2015-09-26

Just run the cron script from time to time.

Optimus, 2015-09-26
Pyan @marrk2

Yes, the removed set_time_limit restrictions do not work on the hosting, they do not work on the server either, I have to remove everything in php.ini. On hosting, they can measure processor time when the limit is exhausted, kill or even block the account.

v- death, 2015-11-25

Use Go))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question