I have a script that reads the directory and make a list of files, including some date about each file. A simple script like millions of others. Depending on the number of files in the directory and the availability of the server (is a shared hosting server), this will result in a timeout error.
Instead of just increase time_limit (might not even to be allowed), I was thinking about to monitor the time remaining each step of the way, I might suspend the task (exit the loop) return the list processed so far, and the process can be resumed from that point with a new request.
This can be done in php? How? What is the alternative excluding time_limit?