博客统计信息

用户名:lzy821218
文章数:297
评论数:93
访问量:341887
无忧币:6134
博客积分:2262
博客等级:6
注册日期:2007-08-08

关于squid for windows 的LOG文件脚本!
2012-02-06 14:55:08

脚本需要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 "\\10.15.0.18\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 laffer.li@51job.com -base64 -charset Gb2312 -s "代理服务器日志打包已完成!"  -base64  -charset Gb2312 -body "声明:  |%date%|%time%|computername dl-VPN-01|IP 10.15.0.2|notify  lzy821218@sina.com|logfile  \\10.15.0.18\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 laffer.li@51job.com -base64 -charset Gb2312 -s "代理服务器操作已完成!"  -base64  -charset Gb2312 -body "声明:  |%date%|%time%|computername dl-VPN-01|IP 10.15.0.2|notify  lzy821218@sina.com|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 laffer.li@51job.com -base64 -charset Gb2312 -s "代理服务器操作已完成!"  -base64  -charset Gb2312 -body "声明:  |%date%|%time%|computername dl-VPN-01|IP 10.15.0.2|notify  lzy821218@sina.com|logfile  f:\squid\log\access.log|comments  squid log file|blat version   "V3.1"
net start squid

分享至
更多
一键收藏,随时查看,分享好友!
0人
了这篇文章
类别:批处理技术圈()┆阅读()┆评论() ┆ 推送到技术圈返回首页

文章评论

 
 

发表评论            

【技术门诊】专家解析:软考重点难点及应试技巧
昵  称:
登录  快速注册
验证码:

请点击后输入验证码博客过2级,无需填写验证码

内  容: