원도우
원도우 IIS 웹로그 삭제 스크립트
변군이글루
2016. 12. 29. 14:22
반응형
원도우 IIS 웹로그 삭제 스크립트
웹로그 삭제 스크립트
- 이 스크립트는 180일이 지난 로그 파일을 삭제하는 기능을 수행합니다.
Option Explicit
' Constants
Const nDays = 180 ' 180일을 상수로 정의
' Arguments
Dim strRootPath
strRootPath = "D:\LogFiles\W3SVC" & WScript.arguments.item(0) & "\"
' FileSystemObject 생성
Dim wFSO
Set wFSO = CreateObject("Scripting.FileSystemObject")
' 지정된 폴더에 대한 Folder 객체 생성
Dim wFolder
Set wFolder = wFSO.GetFolder(strRootPath)
' 폴더 내 파일들을 순회하면서 삭제 조건에 맞는 파일 삭제
Dim wFile
For Each wFile In wFolder.Files
If Int(Now() - wFile.DateLastModified) >= nDays Then
wFile.Delete ' 파일 삭제
End If
Next
' Cleanup
Set wFile = Nothing
Set wFolder = Nothing
Set wFSO = Nothing
사용 방법
cscript DeleteOldLogFiles.vbs <사이트ID>
참고URL
- 이러쿵저러쿵 : http://ooz.co.kr/130
- 이러쿵저러쿵 : http://ooz.co.kr/124
- 채윤이네집 : http://hbesthee.tistory.com/949
- 채윤이네집 : http://hbesthee.tistory.com/538
728x90
반응형