2008年5月15日

產生自動copy log的vb script

需求:自動move 5天前的log,避免主機硬碟滿
動作:move檔案,並紀錄move檔案的log

day3=date-5
year_value=right(datepart("yyyy",day3,1,1),2)
if datepart("m",day3,1,1)<10 then
month_value="0"&datepart("m",day3,1,1)
else
month_value=datepart("m",day3,1,1)
end if
select case month_value
case 1
mend=31
case 2
mend=28
case 3
mend=31
case 4
mend=30
case 5
mend=31
case 6
mend=30
case 7
mend=31
case 8
mend=31
case 9
mend=30
case 10
mend=31
case 11
mend=30
case 12
mend=31
end select

if datepart("d",day3,1,1)<10 then
day_value="0"&datepart("d",day3,1,1)
else
day_value=datepart("d",day3,1,1)
end if

'create batch file
Dim fso, log
Set fso = CreateObject("Scripting.FileSystemObject")
Set log = fso.openTextFile("d:\running\ct-ads2.bat",2,true)
log.WriteLine("echo *********************************** >>d:\log\hinet.log")
log.WriteLine("echo ct-act >>d:\log\hinet.log")
log.WriteLine("move \\192.168.24.34\ct-ads2-log\act\w3svc1\??"&year_value & month_value & day_value &".rar d:\log\ct-ads2-log\act >>d:\log\hinet.log")
log.WriteLine("move \\192.168.24.34\ct-ads2-log\act\w3svc1\??"&year_value & month_value & day_value &".rar d:\log\ct-ads2-log\act >>d:\log\hinet.log")
log.WriteLine("echo *********************************** >>d:\log\hinet.log")
log.Close


沒有留言: