If you have a website and want to know when it goes down, here's how to do it:

Hosting service account that includes NT/IIS, ASP support.
You must have a directory that has write permission for scripts (IIS user) - Some services provide you with one, others allow you to set permissions, and still others require you contact support to have them set permissions.

An ASP page must be accessed from your site after the server restarts for the log entry to occur.
The date & time logged will be that of the first such access, not the actual restart time.
Depending upon the traffic to your site, the server could go down and back up without it being logged before it goes down and up again.

The logging is accomplished by the special global.asa file. If your site already has a global.asa file, you will need to edit it, inserting the code between the SUB and END SUB sections in existing Application_OnStart section of your file. If your site doesn't already have a global.asa file, you can create a file with just the code below, and add it to your root virtual web.


Sub Application_OnStart
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 8,0)
if err then
Set thisfile = fs.OpenTextFile(whichfile, 8,1)
thisfile.writeline "Date & Time of Server Restart"
end if

logwrite= formatdatetime(now(),0)
thisfile.writeline logwrite

set thisfile = nothing
set fs = nothing

End Sub

To read your log file, simply FTP to your virtual server's cgi-bin directory, and grab server.txt.

Or, you can create a web page (log.asp) to display the log. The basic code to do this:


To test the script on your server, create a test.asp file without the Sub and EndSub, load and run it. If the server.txt file doesn't appear in your /cgi-bin directory, you can remove the OnErrorResume next, create an empty server.txt file in the cgi-bin directory, and run the .asp file to see what error you get (probably permissions...). If your host gives write access to a different directory, you can simply change the line that specifies /cgi-bin/server.txt to the desired path.


Site 1999 - 2003 Richard Gamberg  Contact Info