Question

Not sure how to go about this problem that I have. In my website, visitors will look at my product catalogue and place orders, leaving behind their email for contact. I would like my website to automatically process their product's detailed report and store in a temporary folder for 24 hrs. The link will then be emailed to them with a one-time-password. 24hrs later I want the folder removed from my server.

I believe there are website that work similarly.

Question is: Is there anyway that I can program a script to remove folders that have reached their expiry time (24hrs in this case) since the time it was last written to? Or do I have to personally station myself at the server to delete off this folders everyday?

Was it helpful?

Solution

There is number of way to do this, you can use background process, check the expiry when user requests a report or the simplest solution - cron job. Not sure what technology do you use, but this should be a nice tutorial for PHP:

http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/

With ruby on rails you have nice cron support and a railscast explaining it: http://railscasts.com/episodes/164-cron-in-ruby

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top