Answer the question
In order to leave comments, you need to log in
PHP script execution time limit on hosting, how to implement?
Roughly speaking, there is a similar script. I need it to run exactly 3 minutes.
while(true){
"тело скрипта"
sleep(10);
}
$.ajax({
url: "https://url.con/ajax/test.php", // куда отправляем запрос
error: function(){
// будет вызвана в случае если пройдет 3 секунды, но ответа так и не было
alert('no');
},
success: function(){
// что-то делаем тут
alert('good');
},
timeout: 3000 // установка 3-х секундного тайм-аута
});
Answer the question
In order to leave comments, you need to log in
when run in console mode, there are a number of features, for example, by default, the execution time is not limited. check here for details
on each iteration
time() - $_SERVER['REQUEST_TIME'] >= max_execution_time() - 10
Through such a timer, ajax will not be called every three minutes exactly. The timer over time will be more and more late (or will be stopped altogether if the tab is inactive). If the moment is critical with accuracy, you need to write the timer differently and disable "falling asleep" in the browser.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question