關於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 [email protected] -base64 -charset Gb2312 -s "代理服務器日誌打包已完成!"  -base64  -charset Gb2312 -body "聲明:  |%date%|%time%|computername test-01|IP 192.168.0.1|notify  [email protected]|logfile  \\192.168.0.1\f$\I\log file backup\ |comments  cabarc 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 -m  LZX: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 copy  nul f:\squid\log\access.log   
start blat.exe - -to [email protected] -base64 -charset Gb2312 -s "代理服務器操作已完成!"  -base64  -charset Gb2312 -body "聲明:  |%date%|%time%|computername test-01|IP 192.168.0.1|notify  [email protected]|logfile  f:\squid\log\access.log|comments  squid 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 copy  e:\squid\log\access*.log  e:\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 copy  nul e:\squid\log\access.log   
start blat.exe - -to [email protected] -base64 -charset Gb2312 -s "代理服務器操作已完成!"  -base64  -charset Gb2312 -body "聲明:  |%date%|%time%|computername dl-***-01|IP 192.168.0.1|notify  [email protected]|logfile  f:\squid\log\access.log|comments  squid log file|blat version   "V3.1"    
net start squid

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章