use the spiritual-coder's code below with exreme caution and do not use it unless you are an advanced user.
first of all, such a code with no bypass point can cause infinite loops and ghost threads in server. there must be a trick to break out the loop.
i.e. you can use if (file_exists(dirname(__FILE__)."stop.txt")) break; in the loop so if you create "stop.txt", she script will stop execution.
also if you use set_time_limit(86400); instead of set_time_limit(0); your script will stop after one day.