Thursday, November 15        
  Home 
  Search 
  Database 
  File System 
  Components 
  Forms 
  Dates 
  E-mail 
  General 
  The Big List 
  Recent Changes 
  Downloads 
  Feedback 
  Credits 
  Privacy 

   
 Text-only version of aspfaq.com How do I schedule ASP files?
13,269 requests - last updated Thursday, May 24, 2001
 
  1. Use the AT command and Windows Scripting Host (or the more rudimentary task scheduler) to schedule a VBS file at certain intervals. 
     
    First, change the ASP to a VBS file. This is accomplished by (1) changing the extension to VBS; (2) changing all server.createobject calls to createobject; and, (3) removing all <%%> delimiters and any browser-destined code (for example, response.write statement or client-side HTML). I didn't run into any further complications, but YMMV. 
     
    You store the VBS file in the filesystem, and use the AT command to schedule it (this actually schedules its execution with NT's schedule service). At a command prompt, you can use AT by itself to see a list of tasks currently in the schedule. You can use AT /? to find out all its syntax possibilities. 
     
    For example, to get a file to run every weekday at 9:00 am, I launch this batch file (the first line clears existing entries): 
     
        at /delete /y 
        at 9:00 /every:m,t,w,th,f d:\net\shared\getdata.vbs 
     
    Notice there is no web server involved; the file is accessed directly through the file system. Once I got over the "a user has to be logged in" and "the tasks have to be reset when rebooted" hurdles (both of which I believe are problems with the particular machine that is not under our control), all has been running fine for me. 
     
  2. If all you are doing is database work in SQL Server, you might consider using a job. This will allow you to keep all the processing of the job within your database, and prevent the complications associated with multiple systems, connections, and adapting ASP code to be non-ASP-like in behavior. 
     
  3. Kris Eiben suggests: If it's a high-traffic site, you might also be able to put something in session_OnStart, using an application variable with the last time the function was run and checking to see if the right amount of time has passed. 
     
    Along the same lines, check out this article at powerasp.com - it shows you how to use global.asa, a text file and datediff to schedule execution... though timing is never exact because it relies on visitors actually hitting your site. 
     
  4. Build an ASP page and leave a browser open on the machine, with a <meta> refresh (this is by far the ultimate kludge).
 

  

 
Powered by ORCSWeb.com