Groups | Blog | Home
all groups > inetserver asp components > february 2004 >

inetserver asp components : Scheduled tasks


Paul N
2/10/2004 3:46:15 PM
Hi there,

My web app needs to run a schduled task - every hour it
needs to scan the DB, find any updates and - if there are
updates - send an email to an address list, notifyling
them of the change.

I know how to scan the DB for chnages, how to send and
SMTP mail to an address list, and how to set this mail up
such that it gives a simple link to the appropriate place
in the web app - the only thing I lack experience in is
setting up scheduled apps. This would have to be done on
the server (Windows 2000).

I am posting thios question to both the distributed apps
and the servers newsgroups, as it may be appropriate for
either.

Thanks,

lukezhan NO[at]SPAM online.microsoft.com
2/11/2004 2:48:03 AM
Hi Paul,

Thank you for using the community. AS I understand, you want execute a
scheduled task in every hour, scaning the database and sending emails. I
think this may not a proper task in an web application. A web application
will be executed per request. You may consider use the Windows Scheduled
Tasks (Accessories/System Tools). First, create a executable file or script
file which can scan the database and send email, and then adda task in
Windows Scheduled Tasks.

Does this answer your question?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Paul Matear
2/13/2004 1:32:47 AM
it may also be possible to schedule a stored procedure to do this within SQL
itself using Enterprise manager - maybe try posting to
microsoft.public.sqlserver.*

regards
paul

[quoted text, click to view]

Adrian Forbes [ASP MVP]
2/16/2004 11:09:18 PM
As MSFT says, if possible (ie you have access to the server) then convert
your code to VBS (very easy to do as ASP is just VBScript in an ASP page so
you stick the code in a VBS file instead) and you schedule that VBS file to
run.

If you can't do that for whatever reason then there is something you can
kinda hack togther. Store in the Application object the date you want the
thing next run at and on the Session_onStart you check to see if it is after
this date. If it is you run your code and update the date;

sub Session_onStart
if Now > CDate(Application("NextRun")) then
Application.Lock
Application("NextRun") = DateAdd ("h", 1, Now)
Application.UnLock
' now your code to send out your e-mails
end if
end sub

Please note this is pseudo code, I may have the DateAdd stuff a bit wrong
but you get the idea. The downside is that your code runs only when someone
looks at your site after the sheduled time, and that person needs to wait a
while :) You could also put this code in a seperate file and INCLUDE it on
every page, or at least the major ones. That way it is checked every time
someone requests a page.

[quoted text, click to view]

AddThis Social Bookmark Button