Time Activation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zorgi
    Recognized Expert Contributor
    • Mar 2008
    • 431

    Time Activation

    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
    Recognized Expert Expert
    • Jun 2007
    • 6092

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

    I've never had any experience with them though.

    Regards.

    Comment

    • zorgi
      Recognized Expert Contributor
      • Mar 2008
      • 431

      #3
      Thank you markusn00b...

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        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).

        Comment

        • zorgi
          Recognized Expert Contributor
          • Mar 2008
          • 431

          #5
          Thank you Servant. That helps loads.

          Comment

          Working...