본문 바로가기

원도우

[원도우] IIS 웹로그 압축 스크립트

반응형

IIS 웹로그 압축 스크립트

 

1. 사전 작업으로 7z 압축 프로그램 설치

 

2. 웹로그 압축 스크립트

'Do not use {{

 

'strComputer = "."

'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

'Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

 

'For Each objItem in colItems

'          dtmLocalTime = objItem.LocalDateTime

'          dtmMonth = Mid(dtmLocalTime, 5, 2)

'          dtmDay = Mid(dtmLocalTime, 7, 2)

'          dtmYear = Mid(dtmLocalTime, 3, 2)

'Next

 

'dtmDay = dtmDay - 1

'If dtmDay < 10 Then dtmDay = "0" & dtmDay

 

'}} Do not use

 

zipcmd = """C:\Program Files\7-Zip\7z.exe"""

workdir = "D:\LogFiles\W3SVC1\"

 

Set WshShell = CreateObject("WScript.Shell")

Set fso = CreateObject("Scripting.FileSystemObject")

 

For i = 1 To 30

           temp = Replace( DateAdd( "d", -i, Date() ), "-", "" )

           yy = Mid( temp, 3, 2 )

           mm = Mid( temp, 5, 2 )

           dd = Mid( temp, 7, 2 )

           'Wscript.Echo yy & mm & dd

 

           '일 단위 압축

           strLogFile = "u_ex" & yy & mm & dd & ".log"

           'Wscript.Echo workdir & strLogFile

           If fso.FileExists( workdir & strLogFile ) Then

                     'Wscript.Echo zipcmd & " a """ & workdir & strLogFile & ".gz"" """ & workdir & strLogFile & """"

                     WshShell.Run zipcmd & " a """ & workdir & strLogFile & ".gz"" """ & workdir & strLogFile & """", 0, true

                     fso.DeleteFile workdir & strLogFile

           End If

 

           '시간 단위 압축

           For h = 23 To 0 Step -1

                     hh = CStr( h )

                     If Len( hh ) < 2 Then hh = "0" & CStr( h )

                                'Wscript.Echo yy & mm & dd && hh

                                strLogFile = "u_ex" & yy & mm & dd & hh & ".log"

                                'Wscript.Echo workdir & strLogFile

                                If fso.FileExists( workdir & strLogFile ) Then

                                          'Wscript.Echo zipcmd & " a """ & workdir & strLogFile & ".gz"" """ & workdir & strLogFile & """"

                                          WshShell.Run zipcmd & " a """ & workdir & strLogFile & ".gz"" """ & workdir & strLogFile & """", 0, true

                                          fso.DeleteFile workdir & strLogFile

                     End If

           Next

Next

 

7z 다운로드 URI : http://www.7-zip.org/download.html

 

iisweglogcompress.txt

728x90
반응형