Forum Moderators: open

Message Too Old, No Replies

ASP question

How can I run housekeeping tasks automatically?

         

themoff

5:00 pm on Aug 11, 2001 (gmt 0)

10+ Year Member



Hi everyone,
On my site I have several routines that need calling once a day to do stuff like backup logfiles, reset counters, blah blah blah. At the moment I achieve this by getting the index.asp to check every time it is loaded to see if it is time to do the housekeeping. This works well enough, because enough people visit to make sure index.asp is run often, but I don't get that many people that it is too much of a drain on the server to run this code everytime I get a visitor.

My problem is that I am looking at moving away from the index.asp to index.html, i.e. there won't be an ASP page regularly called, and therefore that can check on housekeeping times.

Is there any other way to get my site to execute a given file or routine? My site is hosted on a shared IIS 5 server.

Cheers, Robin

Xoc

12:27 am on Aug 12, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes. Just create a batch file to do the routine stuff. Then use the Windows Scheduled Tasks (Start ¦ Programs ¦ Accessories ¦ System Tools ¦ Scheduled Tasks) to run the batch file. You can set it up to run as often as you want on any schedule. I use it for generating web statistics that get posted to my web site nightly.

themoff

3:52 pm on Aug 12, 2001 (gmt 0)

10+ Year Member



Hi Xoc,
Thanks for the info, but I don't have that kind of access to the server. I'm thinking that the global.asa is probably the way forward - I've done some reading cos I'd never used it before, and it I think it'll do what I want. However, I've hit a big problem with it, that I hope someone can help me with.
I get this error
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.(#3001)
when I try to open a recordset with the following query:
SELECT Teachers.Country FROM Teachers GROUP BY Teachers.Country HAVING (((Teachers.Country) Is Not Null)) ORDER BY Teachers.Country;

The identical code works perfectly when run from a normal .asp file, or as a query in MS Access. Why shouldn't it work in global.asa?

TIA, Robin

Xoc

9:37 pm on Aug 12, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think global.asa is the right answer. The Application_OnStart will only get run when the web server is restarted. In a perfect world, that would be never!

The Session_OnStart gets executed each time you get a new visitor. However, for performance reasons, you should have Sessions turned off unless you really have a good reason for using them. If you have Sessions turned off, then the Session_OnStart will never run.

Since you can't do Scheduled tasks on the server, I suggest creating one ASP page to do your periodic tasks. Then from your client machine set up a scheduled task to view the web page. The task to run would be:

start iexplore [domain.com...]

themoff

7:54 am on Aug 13, 2001 (gmt 0)

10+ Year Member



HI Xoc,
Thanks, I'll try what you say.
I'm still keen to resolve that DB error - can anyone shed any light on it? All I can find is this from the MS knowledge base [support.microsoft.com]

Cheers, Robin