IIS日志删除脚本

[ 2004/10/21 09:07 | by gOxiA ]
How can I delete all files from my IIS log file directory that are over 90 days old?

这个脚本可以从日志目录中删除90天的记录。

Option Explicit
Const GENERAL_FAILURE = 2
Const KillFile=0 ' Set this to 0 to not delete the files, set to 1 to delete the files

Dim ArgObj, Servername, WebSiteID, WebSite, WebSitepath, totalDeleted, MaxAgeOfFileToKeep

Function DeleteOldLogFiles(WebSite,  MaxAgeOfFile)
Dim File, ServerObj, FSO, FolderObj, FileObj, LogFileDir, Deleted, Status, FailedToDelete
Deleted = 0
FailedToDelete= 0
on error resume next
' Attempt to get the web site object from the metabase
Err.clear
Set ServerObj = GetObject(WebSite)
If (Err.Number <> 0) Then
  WScript.Echo \"Error: \" & Err.Description & \" (\" & Err.Number & \")\"
  Exit Function
end if
LogFileDir = ServerObj.LogFileDirectory
Set ServerObj = Nothing
WScript.Echo \"Log file dir for: \" &WebSite & \" = \" & LogFileDir
WScript.Echo \"Delete files over \"& MaxAgeOfFile & \" days old.\"
WScript.Echo \"\"
Set FSO = CreateObject(\"Scripting.FileSystemObject\")
set Folderobj = FSO.GetFolder(LogFileDir)
for each File in Folderobj.files
 if (Date - File.DateCreated > cint(MaxAgeOfFile)) then
        Status = \"Deleting File: \" & File.name & \", Age=\" & formatNumber(Date-File.DateCreated, 0) & \" days, Status=\"
        Err.Clear
        if (KillFile = 1) then
            FSO.DeleteFile(LogFileDir & \"\" & File.Name)
            If (Err.Number <> 0) Then
                   Status = Status & \"Failed : \"& Err.Description & \" (\" & Err.Number & \")\"
                   FailedToDelete = FailedToDelete +1
           else      
                Status = Status & \"Deleted\"
               Deleted = Deleted + 1
            end if
      else
           Status = Status & \"Skipped\"
       end if
       WScript.Echo Status  
 end if
next
DeleteoldLogfiles = Deleted
WScript.Echo \"\"
if (FailedToDelete > 0) then
  WScript.Echo \"There were \" & FailedToDelete  & \" files that could not be deleted.\"
end if
WScript.Echo \"There were \" & Deleted & \" files deleted.\"
end function
Sub DisplayHelpMessage()
   WScript.Echo
   WScript.Echo \"Usage:\"
   WScript.Echo \"      DeleteOldWebSiteLogfiles.VBS MaxDays WebSiteNumber \"
   WScript.Echo
   WScript.Echo \"MaxDays = maximum age in days of files to keep.\"
   WScript.Echo \"WebSiteNumber is the number of the web site, you have two methods to determine this:\"
   WScript.Echo
   WScript.Echo \"#1 = Run FINDWEB.VBS\"
   WScript.Echo \"#2 = Right click the web site, select properties, on the web site tab\"
   WScript.Echo \"     under logging click the Properties button, part of the log file\"
   WScript.Echo \"     name will contain the web site #\"
   WScript.Echo
   WScript.Echo \"     example log filename: W3SVC1\exyymmdd.log  - the web site is 1\"
   WScript.Echo \"                           W3SVC45\exyymmdd.log - the web site is 45\"
   WScript.Echo
   WScript.Echo \"Please visit and support : http://www.iisfaq.com\"
end sub
' Get the Arguments object
Set ArgObj = WScript.Arguments
' Test to make sure there is at least one command line arg - the command
If ArgObj.Count < 2 Then
       DisplayHelpMessage
       WScript.Quit (GENERAL_FAILURE)
End If
Servername = \"LocalHost\"
MaxAgeOfFileToKeep = trim(ArgObj(0))
WebSiteID    = trim(ArgObj(1))
WebSite        = \"W3SVC/\" & WebSiteID
WebSitepath = \"IIS://\" & Servername &\"/\" & WebSite
TotalDeleted = DeleteOldLogFiles(WebSitePath,  MaxAgeOfFileToKeep)

有效提高Serv-U的吞吐量

[ 2004/10/16 10:29 | by gOxiA ]
进入Setting-Advanced
将Send buffer和Receive buffer的两项值设置为32768

副作用:如果服务器的性能不够强劲,会增加当机的可能性。

关于Win2003下ASP无故停止

[ 2004/10/13 17:33 | by gOxiA ]
微软已经承认,在win2003下运行access数据库的站点,会遇到ASP突然停止工作的故障
主要是因为session造成的,相关文档:
http://support.microsoft.com/?id=307598

解决方法,安装相应更新文件,参考网址:http://www.aspfaq.com/show.asp?id=2356
1、安装MDAC2.8,http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&DisplayLang=en

2、安装MDAC关键更新Microsoft Data Access Components (MDAC) Security Patch MS04-003 (32-bit),http://www.microsoft.com/downloads/details.aspx?FamilyId=39472EE8-C14A-47B4-BFCC-87988E062D91&displaylang=en

3、安装Jet 4.0 Service Pack 8 (SP8) for Windows Server 2003 (KB829558),http://www.microsoft.com/downloads/details.aspx?familyid=97bc8126-5c60-44bc-a2ce-1e40c7fe2b34&displaylang=en
分页: 467/472 第一页 上页 462 463 464 465 466 467 468 469 470 471 下页 最后页 [ 显示模式: 摘要 | 列表 ]