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
apache滚动日志,自动重命名的脚本
最新推荐文章于 2024-08-15 20:22:12 发布