I am looking for a way to have a script run every day at 5am to delete the contents of a Temp folder. The following is the method I am considering. I would appreciate any thoughts on this or suggestions for other methods. I want to keep everything local, so that there are no external dependencies from outside my account on Discount ASP hosting.
- Have a textfile containing the datetime of the next desired run (5:00am tomorrow).
- Have a Datetime cache value that expires after (one hour?)
- When someone hits the website and the cache is expired, reload the datetime into cache
- If the Datetime has passed, run the script to be ‘scheduled’ and add 24 hours to the DateTime in the file
Your comments are appreciated.
You are on the right way. Here is a good article how to achieve this.
Also, based on your comment, why not use session end event to purge? Also, you can hook to application end as well, just in case.