Setting something to work only once every 10 minutes?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sephiriz
Forum Newbie
Posts: 5
Joined: Thu Jul 31, 2003 1:34 pm

Setting something to work only once every 10 minutes?

Post by Sephiriz »

I have a certain script that I only want a person to be able to execute once every 10 minutes.

I can think of some possiblities as to how to set this, but are there any specific functions that can help me in this, and any simple way I can do this?

I was thinking that you do something with MySql where you make a column, then when you start the script you take the time, and send that time to the Mysql database, and then make a check in the script that it only works if the current time is +10 to that stored in the table.

Any suggestions? Help appreciated very much, this is my first time posting here, so I'm sorry if this seems a stupid question.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

if you're on a *nix machine, you can use cron to do this for you
Sephiriz
Forum Newbie
Posts: 5
Joined: Thu Jul 31, 2003 1:34 pm

Post by Sephiriz »

Yes, thats a problem I forgot too mention, I do not have Cron enabled on this web server.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

have a table with a timestamp.
each time a user does it it'll first check the timestamp of he last one. if it's less than 10 min ago return an error. otherwise update the row (which will update the timestamp) and allow the user to do that
Sephiriz
Forum Newbie
Posts: 5
Joined: Thu Jul 31, 2003 1:34 pm

Post by Sephiriz »

Ok, thanks.
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post by jmarcv »

...or set a 10 minute cookie.
Post Reply