IIS Log 留太多也只是佔用空間,最好的方式就是用排程定期刪除
用 VBScript 來進行 30 天前的資料刪除
sLogFolder = "c:\inetpub\logs\LogFiles" 'IIS Log 存放資料夾
iMaxAge = 30 'in days
Set objFSO = CreateObject("Scripting.FileSystemObject")
set colFolder = objFSO.GetFolder(sLogFolder)
For Each colSubfolder in colFolder.SubFolders
Set objFolder = objFSO.GetFolder(colSubfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
iFileAge = now-objFile.DateCreated
if iFileAge > (iMaxAge+1) then
objFSO.deletefile objFile, True
end if
Next
Next
將上面 Script 存檔後,設定每天執行的排程,即可完成每天刪除 30 天以前的 IIS Log
參考文章: Prevent IIS log files from using too much disk space on Windows Server | Computerworld
沒有留言:
張貼留言