
Can anyone help me with this please.
I am using the following bat file code to search through an IIS log file a return the total count of GET requests.
Code: Select all
@ECHO OFF
SET logfolder=\\127.0.0.1\c$\WINDOWS\system32\LogFiles\W3SVC1
SET /a counter=0
:: get newest file
FOR /F %%f IN ('DIR %logfolder% /B /O:D') DO SET newestfile=%%f
:: copy newest file to temp file
COPY "%logfolder%\%newestfile%" c:\temp\xx.log > NUL
:: process each line in the file
FOR /F "usebackq delims=" %%l in (c:\temp\xx.log) DO (
FOR /F "tokens=7 delims= " %%a in ("%%l") DO (
IF %%a == GET SET /a counter+=1
)
)
:: output to console
ECHO %counter%:Ok
:: delete temp file
DEL c:\temp\xx.log > NUL
Now I only want a return count of GET request that happened within the previous 5 minutes. So somehow in this batch file i need
to get the current system date and time. Minus 5 minutes and then count values in between these times.
2013-07-24 23:59:59
Return all GET request in between
2013-07-24 23:54:59
Thanks for any help.