I am running a cron job that runs a PHP script every minute ... however my ISP doesnt like that so I will eventually have to change it to every 5 min ... my problem is this the PHP script is going out to a shoutcast server getting the needed information and then writing it to a file for me but when I tell it to run and then sleep for 20 seconds for some reason it doesnt rerun at the 20 second marker it only runs once every minute ... I need it to run the process at least once every 15-20 seconds ... can some one write the loop part of this or explain how I could do this as its the only part of my project that is NOT complete ...

Thanks
Midnite

Every 15 seconds? That's a really short interval! It seems like this would add a constant load on the server (therefore taking processing power away from user requests). I suggest you stick to a bit longer of an interval, maybe 10 minutes?

But to create a loop with a delay...

$counter = 0;
while(true)
{
  if($counter==100) break;
  $counter++;
  sleep(20); //Wait 20 seconds
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.