Server-side Batch process in a shared hosting enviroment
-
11-09-2019 - |
Question
I'm writing a website that will be hosted on a shared hosting environment. As a consequence, I won't have any access to things such as the task scheduler. The website needs to perform various checks on a half-daily basis. What is the best way of firing these tasks in this scenario?
The best two things I could think of where:
- Fire the process every time a user hits my site - perform some sort of check to see when the process last ran, and if it's greater then 12 hours run the process.
- Have some hidden page that runs the processes and then get some external entity to ping this page at 12 hour intervals.
Both methods seem a bit ropey?
Solution
you can use a little trick that uses the asp.net cache.
OTHER TIPS
Definitely don't use your option #2, unless you have some kind of protection against running it accidentally.
You also don't want your processing to depend on user requests. What happens if you have a very slow day (say a holiday combined with a large fiber cut somewhere) and no one hits the site for a while?