Connecting Tech Pros Worldwide Forums | Help | Site Map

Time Activation

zorgi's Avatar
Member
 
Join Date: Mar 2008
Location: here
Posts: 107
#1: Mar 27 '08
Hello everyone

I want to know if there is a way of running PHP script without visiting the page where the script is. Better,.... can that scrip / function be time activated.

I do not have any code to post, but lets assume we have function deleteBooking($booking_Id) that deletes provisional booking after 48 hours automatically if booking has not been confirmed. Is there a way to tell server to execute this function after 48 hours has expired.

If there is no way of doing this using php have you came across similar problem and how did you solve it?

Big Thanks

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#2: Mar 27 '08

re: Time Activation


I've heard about using cronjobs - if your server supports them.

I've never had any experience with them though.

Regards.
zorgi's Avatar
Member
 
Join Date: Mar 2008
Location: here
Posts: 107
#3: Mar 27 '08

re: Time Activation


Thank you markusn00b...
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#4: Mar 27 '08

re: Time Activation


Yeah, you can use a cronjob and run it every 30mins or something to check the database for expired bookings. The only problem is, then if someone's booking expires on the 31st minute (one minute after the cronjob was last run) the booking will be there for 48 hours and 29mins. You can make the cronjob run every minute, but it could be a bit of a server load and is likely to crash the system if you have a large amount of data.

Alternatively, if you use a sign in system, then every page load it can check if that user's booking is expired and if so it will remove the link or redirect or something. That way you don't need cronjobs to run quite so often. You could have a cronjob set to clean the database every hour or day, and just check for user specific expired data on every page load (or atleast every relavent page load).
zorgi's Avatar
Member
 
Join Date: Mar 2008
Location: here
Posts: 107
#5: Mar 28 '08

re: Time Activation


Thank you Servant. That helps loads.
Reply