ykwll 发表于 2018-12-27 10:47:04

关于squid for windows 的LOG文件脚本!

  脚本需要blat.exe、 forfile.exe文件,将这两个文件放入到%systemroot%\system32目录下!
  1、日记文件打包后删除脚本.bat
  @echo off   
FOR /F "eol=; tokens=1,2 delims= "%%i in ('DATE /T') Do SET a=%%i   
FOR /F "eol=; tokens=1,2 delims= "%%i in ('DATE /T') Do SET b=%%j   
FOR /F "eol=; tokens=1,2 delims=: " %%i in ('TIME /T') Do Set HHMM=%%i%%j   
cabarc N "\\192.168.0.1\f$\I\log file backup\EventLogs_%computername%_%a%_%b%_%HHMM%.cab" "e:\squid\bak\access*.log"   
cabarc N "e:\squid\bak\EventLogs_%computername%_%a%_%b%_%HHMM%.cab" "e:\squid\bak\access*.log"   
del /Q e:\squid\bak\access*.log   
forfiles /p E:\squid\bak /m EventLogs*.cab -d -31 /c "cmd /c del /f @path"   
start blat.exe - -to lzy821218@运维网.com -base64 -charset Gb2312 -s "代理服务器日志打包已完成!"-base64-charset Gb2312 -body "声明:|%date%|%time%|computername test-01|IP 192.168.0.1|notifylzy821218@sina.com|logfile\\192.168.0.1\f$\I\log file backup\ |commentscabarc squid log file|blat version   "V3.1"
  rem FOR /F "eol=; tokens=1,2* delims= "%%i in ('DATE /T') Do SET a=%%i   
rem FOR /F "eol=; tokens=1,2 delims= "%%i in ('DATE /T') Do SET b=%%j   
rem {eol=;}忽略分号   
rem {delims= }以空格作为分割符   
rem {tokens=1,2} 提取分割后的1和2的内容
  rem forfiles /p e:\squid\log /m access*.log -d -31 /c "cmd /c del /f @path"
  rem cabarc N 新建一个打包文件
  rem cabarc -mLZX:21-r -p N "d:\bak\EventLogs_%computername%.cab" "D:\share\*.*"
  2、代理服务器日志文件处理(计算文件大小).bat
  @echo off   
for %%1 in ("f:\squid\log\access.log")do if %%~z1 geq 5242880 goto A   
for %%2 in ("f:\squid\log\access.log")do if %%~z2 lss 5242880 goto B   
:A   
net stop squid /y   
rem pause wait...   
For /F %%i In ('date /t') do ren f:\squid\log\access.log access%%i.log   
forfiles /p f:\squid\log /m access*.log -d -31 /c "cmd /c del /f @path"   
type null > f:\squid\log\access.log   
ram copynul f:\squid\log\access.log   
start blat.exe - -to lzy821218@运维网.com -base64 -charset Gb2312 -s "代理服务器操作已完成!"-base64-charset Gb2312 -body "声明:|%date%|%time%|computername test-01|IP 192.168.0.1|notifylzy821218@sina.com|logfilef:\squid\log\access.log|commentssquid log file|blat version   "V3.1"   
net start squid   
:B   
exit
  3、squidlog-oneday.bat
  @echo off   
net stop squid /y   
rem pause wait...   
For /F %%i In ('date /t') do ren e:\squid\log\access.log access%%i.log   
For /F %%i In ("e:\squid\log") do copye:\squid\log\access*.loge:\squid\bak\access*.log   
For /F %%i In ("e:\squid\log") do del/q e:\squid\log\access*.log   
type null > e:\squid\log\access.log   
rem copynul e:\squid\log\access.log   
start blat.exe - -to lzy821218@运维网.com -base64 -charset Gb2312 -s "代理服务器操作已完成!"-base64-charset Gb2312 -body "声明:|%date%|%time%|computername dl-***-01|IP 192.168.0.1|notifylzy821218@sina.com|logfilef:\squid\log\access.log|commentssquid log file|blat version   "V3.1"   
net start squid



页: [1]
查看完整版本: 关于squid for windows 的LOG文件脚本!