apache滚动日志,自动重命名的脚本
2010-02-03 14:33
169 查看
on error resume next
Dim Fso,f, f1,s,m,AExists,EExists,LogExists,Sh,ELogExists
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Sh=CreateObject("Wscript.Shell")
s=Hour(Now())
if (s>=0 and s<=9) then
s="0" & s
end if
n=minute(Now())
if (n>=40) then
Sh.exec("net stop arc_apache_access_file")
Sh.exec("net stop arc_apache_error_file")
end if
wscript.sleep 15000
select case s
case 00
AExists = Fso.fileExists("c:/httplog/access_log.00")
if AExists=true then
LogExists=Fso.fileExists("c:/httplog/access_log")
if LogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/access_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/access_log.24")
f1.name="access_log"
end if
else
set f1=fso.getfile("c:/httplog/access_log.24")
f1.name="access_log"
End if
End if
EExists = Fso.fileExists("c:/httplog/error_log.00")
if EExists=true then
ELogExists=Fso.fileExists("c:/httplog/error_log")
if ELogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/error_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/error_log.23")
f1.name="error_log"
end if
else
set f1=fso.getfile("c:/httplog/error_log.23")
f1.name="error_log"
End if
End if
case 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
t=s-1
if (s>=0 and s<=9) then
t="0" & t
end if
m="c:/httplog/access_log."&s
AExists = Fso.fileExists(m)
if AExists=true then
LogExists=Fso.fileExists("c:/httplog/access_log")
if LogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/access_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/access_log."& t )
f1.name="access_log"
end if
else
set f1=fso.getfile("c:/httplog/access_log." & t)
f1.name="access_log"
End if
End if
EExists = Fso.fileExists("c:/httplog/error_log." & s)
if EExists=true then
ELogExists=Fso.fileExists("c:/httplog/error_log")
if ELogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/error_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/error_log."& t)
f1.name="error_log"
end if
else
set f1=fso.getfile("c:/httplog/error_log."& t)
f1.name="error_log"
End if
End if
End select
if (n>=40) then
Sh.exec("net start arc_apache_access_file")
Sh.exec("net start arc_apache_error_file")
end if
Dim Fso,f, f1,s,m,AExists,EExists,LogExists,Sh,ELogExists
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Sh=CreateObject("Wscript.Shell")
s=Hour(Now())
if (s>=0 and s<=9) then
s="0" & s
end if
n=minute(Now())
if (n>=40) then
Sh.exec("net stop arc_apache_access_file")
Sh.exec("net stop arc_apache_error_file")
end if
wscript.sleep 15000
select case s
case 00
AExists = Fso.fileExists("c:/httplog/access_log.00")
if AExists=true then
LogExists=Fso.fileExists("c:/httplog/access_log")
if LogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/access_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/access_log.24")
f1.name="access_log"
end if
else
set f1=fso.getfile("c:/httplog/access_log.24")
f1.name="access_log"
End if
End if
EExists = Fso.fileExists("c:/httplog/error_log.00")
if EExists=true then
ELogExists=Fso.fileExists("c:/httplog/error_log")
if ELogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/error_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/error_log.23")
f1.name="error_log"
end if
else
set f1=fso.getfile("c:/httplog/error_log.23")
f1.name="error_log"
End if
End if
case 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
t=s-1
if (s>=0 and s<=9) then
t="0" & t
end if
m="c:/httplog/access_log."&s
AExists = Fso.fileExists(m)
if AExists=true then
LogExists=Fso.fileExists("c:/httplog/access_log")
if LogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/access_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/access_log."& t )
f1.name="access_log"
end if
else
set f1=fso.getfile("c:/httplog/access_log." & t)
f1.name="access_log"
End if
End if
EExists = Fso.fileExists("c:/httplog/error_log." & s)
if EExists=true then
ELogExists=Fso.fileExists("c:/httplog/error_log")
if ELogExists=true then
if n>=40 then
set f1=fso.getfile("c:/httplog/error_log")
f1.delete
wscript.sleep 5000
set f1=fso.getfile("c:/httplog/error_log."& t)
f1.name="error_log"
end if
else
set f1=fso.getfile("c:/httplog/error_log."& t)
f1.name="error_log"
End if
End if
End select
if (n>=40) then
Sh.exec("net start arc_apache_access_file")
Sh.exec("net start arc_apache_error_file")
end if
相关文章推荐
- 脚本要求:两类机器一共300多台,写个脚本自动清理这两类机器里面的日志文件。
- Nginx 日志自动分割脚本
- Apache/Nginx 访问日志分析脚本 推荐
- linux apache 自动监护脚本
- 自动过滤邮箱日志,并发送邮件给邮箱脚本,perl+shell
- 日志/数据自动压缩备份删除小脚本
- 智能监测自动重启Apache服务器的Shell脚本
- 自动删除oracle归档日志脚本及实现
- 游戏日志自动抓取添加server脚本
- shell脚本自动清理服务器日志和图片
- linux自动清理日志脚本
- DB2归档日志的开启已经自动备份后清理归档的脚本
- 《设置定时自动清理归档日志脚本 》
- 【Linux笔记】如何利用logrotate工具自动切分滚动中的日志文件
- shell脚本:自动内存监控及日志备份
- 自动发送密码抓取远程日志 Shell脚本实现代码
- linux 自动清除三天日志脚本
- 不再担心日志文件过大:通用日志滚动脚本
- 不再担心日志文件过大:通用日志滚动脚本 推荐
- apache 2.4.4 自动分割日志,按年月日生成