변군이글루

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

축___원도우

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

변군 변군이글루 2016.12.29 14:14

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

저작자 표시
신고
0 Comments
댓글쓰기 폼
Prev 1 2 3 4 5 6 7 8 9 ... 582 Next