@echo off
set hours=%time:~0,2%
:: 当前小时减1,如果是0点则把时间设置为23点,注意if else 不能分行写
if "%hours: =0%"=="00" (set hours=23) else (set /a hours=%hours%-1)
:: 设置数据库保存的日期时间,格式:年-月-日 时
set logdate=%date:~0,4%-%date:~5,2%-%date:~8,2% %hours: =0%
:: 设置日志文件路径
set logname=D:\iislog\W3SVC2\u_ex%date:~2,2%%date:~5,2%%date:~8,2%%hours: =0%.log
echo 正在分析日志:%logname%
"C:\Program Files (x86)\Log Parser 2.2\logparser.exe" "SELECT c-ip as cip,count(0) as counts,'%logdate%' as AddDate FROM '%logname%' TO IISLog_IpCount where cs(User-Agent) not like '%%spider%%' group by c-ip having count(0)>1000 order by count(0) desc" -o:SQL -server:192.168.1.200 -driver:"SQL Server" -database:WKSM -username:log_com -password:sqladmin!@#
pause