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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值