Page 1 of 1

howto: schedule a call to a php-page every 5 seconds

Posted: Fri Aug 08, 2003 6:19 am
by flummi
Hi there, :roll:

I have written a php page to update my database with data from files and i want to have this script to be called every 5 seconds. How can I do this?
Is it possible to schedule this call on the server? And how?
I do have full root access to the server so I should have all possiblilities to do this.

Thanx for any help,
Flummi

Posted: Fri Aug 08, 2003 6:50 am
by devork
check out sleep() function
=---------show.php
...
.
..
.
sleep(4);
header("Location:show.php");
=--------------------
give the same page name in location header

Posted: Fri Aug 08, 2003 8:12 am
by nielsene
If you're on a *nix machine use cron.

Posted: Sat Aug 09, 2003 5:10 am
by tylerdurden
Isn't the min interval for cron 1 min? ;-)

Posted: Sat Aug 09, 2003 10:03 am
by nielsene
Oops, true.

Posted: Sat Aug 09, 2003 10:44 pm
by jason
Important question: Why would you want something run every 5 seconds? Why not just run the program, and let it run. And then let the program operate every 5 seconds?

It would be better if you explained what you are trying to do, rather than have us try to help you put together a solution that may be the wrong solution.

Example of why this is bad. You hire someone to build you a table. They build you a table. But what you really needed was 6 chairs. Sure, they can help you build a great table, but it doesn't solve the real problem: that problem being seating.

Posted: Sun Aug 10, 2003 5:39 am
by JAM
...also.

If you got 2 users/h, why update the database making the server work for nothing? Adding an "update table..." in the beginning of the sites backend could help, but if you got 1000's of visits/min, you get high loads.

Workaround could be to increase a value on each visit, and when it hits a certain amout (or a certain time()-(time()-5) has passed, do the update.

Just my 2 cents...