您的位置:首页 > 运维架构 > Apache

apache滚动日志,自动重命名的脚本

2010-02-03 14:33 134 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: