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)

关于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
IIS 6 出于安全考虑, 默认最大请求200K(也即最大提交数据限额为200KByte, 204800Byte).

解决办法:

1. 关闭 IIS Admin Service 服务

2. 打开 \Windows\system32\inesrv\metabase.xml

3. 修改 ASPMaxRequestEntityAllowed 的值为自己需要的, 默认为 204800

4. 启动 IIS Admin Service


Addon: 解决方法2

1. 新建文本文件:
'use VBS
set obj1=GetObject(\"winmgmts:/root/MicrosoftIISv2\")
set obj2=obj1.get(\"IIsWebVirtualDirSetting='W3SVC/1/ROOT'\")
'Output default value
WScript.Echo \"AspMaxRequestEntityAllowed Default Value: \" & obj2.AspMaxRequestEntityAllowed
'Reset the value
obj2.AspMaxRequestEntityAllowed=1024000 ' set to 1mbyte, u can set to other what you want :)
' Save data
obj2.Put_()
'Output new value
WScript.Echo \"AspMaxRequestEntityAllowed New Value: \" & obj2.AspMaxRequestEntityAllowed


2. 保存为
requestchange.vbs


3. 进入命令行, 运行:
cscript [path]requestchange.vbs
分页: 14/14 第一页 上页 9 10 11 12 13 14 最后页 [ 显示模式: 摘要 | 列表 ]