Questions about ignore_user_abort

Please take a look at the code first:

ignore_user_abort(true);
set_time_limit(0);
ini_set("memory_limit","512M");

while(true){
    file_put_contents("./Log.txt","000 ",FILE_APPEND);
    sleep(60);
}

above is a piece of code similar to a scheduled task I found on the Internet. when the browser is closed, it makes sense that the program should be written to the file every 10 seconds, which is repeated over and over again.

but the reality is: the program doesn"t run all the time, and after about 20 minutes, the program stops (after writing about 20 times, it no longer writes to the file)

excuse me, why is this? Shouldn"t it be executed until, for example, the server is restarted? Thank you!

Php
Mar.09,2022

set the path of error_log in php.ini, and go to see log after reproduction. Make sure the log directory has permissions.


how did it become 10 seconds when it was 60 seconds?

Menu