Dealing with dates for doing 7 days of log files is cumbersome with a batch file but it can be done.
I move the previous days log files (Imail,declude) of of 3 servers and rename them for tracking purposes with a batch file. A second set of batch files zips up the corresponding days log file from the previous month (we keep 1 month unzipped for scanning) and monthly will remove old zipped logs according to our policies. This uses pkzip rather than winzip. Not an elegant solution I admit but it works. The key for me was getting the date into DOS variable and dealing with DOS's math to set previous dates. It worked for us a the time and we have not changed. I try and can break out the main parts of this if any one want to kludge up their own batch file vs. VB or some other script. Stu At 04:37 PM 4/17/2006 -0700, you wrote: >But again, if Windows sees the file as 12:00 AM 04/17/06 rather than >11:59:59 PM 04/16/06 and you are running the script on 04/17/06 then it will >not include yesterday's log as Windows says it was modified today. > > > >FYI, I am doing this for IIS logs, KIWI logs as well as Declude logs so I am >looking for a universal solution. > > > >John T > >eServices For You > > > >"Seek, and ye shall find!" > > > >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On Behalf Of Dean Lawrence >Sent: Monday, April 17, 2006 11:36 AM >To: [email protected] >Subject: Re: [Declude.JunkMail] OT: Help with WinZip command line > > > >John, > > > >I run the following 2 commands on my daily IIS log files. > > > >forfiles /p c:\clients /s /d -3 /m ex*.log /c "cmd /c wzzip @fname.zip >@file" > > > >forfiles /p c:\clients /s /d -3 /m ex*.log /c "cmd /c del @file" > > > >I keep each of my clients log files underneath their own client directory so >I use forfiles to identify the log files and zips anything that is older >than 3 day (so that I can review if something happened over the weekend). I >then run the same command, but using delete instead of wzzip. Both of these >commands are in a simple bat file that I call from windows scheduler. > > > >Hope it helps, > > > >Dean > > > > > >On 4/17/06, John T (Lists) <[EMAIL PROTECTED]> wrote: > >I am trying to create a batch file that will zip up a weeks worth of logs >and then move that zip file. > >The problem I am having is that I want to zip the previous 7 days, but >sometimes the last log is time stamped say 04/16/06 11:59 PM and sometimes >say 04/17/06 12:00 AM. Because of that, if I run the batch file on 04/17/06, > >it may or may not include the log file for 04/16/06 depending on the final >time stamp. > >Other than stopping services just before midnight and then restarting, what >is the best way to always ensure that I am processing the correct day's >files? > >John T >eServices For You > >"Seek, and ye shall find!" > > > >--- >This E-mail came from the Declude.JunkMail mailing list. To >unsubscribe, just send an E-mail to [EMAIL PROTECTED], and >type "unsubscribe Declude.JunkMail". The archives can be found >at http://www.mail-archive.com. > > > > >-- >__________________________________________ >Dean Lawrence, CIO/Partner >Internet Data Technology >888.GET.IDT1 ext. 701 * fax: 888.438.4381 >http://www.idatatech.com/ <http://www.idatatech.com/> >Corporate Internet Development and Marketing Specialists > ><html> > ><head> ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> > > ><meta name=Generator content="Microsoft Word 10 (filtered)"> > ><style> ><!-- > /* Font Definitions */ > @font-face > {font-family:Tahoma; > panose-1:2 11 6 4 3 5 4 4 2 4;} >@font-face > {font-family:Verdana; > panose-1:2 11 6 4 3 5 4 4 2 4;} > /* Style Definitions */ > p.MsoNormal, li.MsoNormal, div.MsoNormal > {margin:0in; > margin-bottom:.0001pt; > font-size:12.0pt; > font-family:"Times New Roman";} >a:link, span.MsoHyperlink > {color:blue; > text-decoration:underline;} >a:visited, span.MsoHyperlinkFollowed > {color:blue; > text-decoration:underline;} >p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig > {margin:0in; > margin-bottom:.0001pt; > font-size:12.0pt; > font-family:"Times New Roman";} >span.EmailStyle18 > {font-family:Verdana; > color:navy;} >@page Section1 > {size:8.5in 11.0in; > margin:1.0in 1.25in 1.0in 1.25in;} >div.Section1 > {page:Section1;} >--> ></style> > ></head> > ><body lang=EN-US link=blue vlink=blue> > ><div class=Section1> > ><p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size: >10.0pt;font-family:Verdana;color:navy'>But again, if Windows sees the file as </span></font><font size=2 color=navy face=Verdana><span style='font-size:10.0pt;font-family:Verdana; > color:navy'>12:00 AM</span></font><font size=2 color=navy face=Verdana><span >style='font-size:10.0pt;font-family:Verdana;color:navy'> </span></font><font size=2 color=navy face=Verdana><span style='font-size:10.0pt;font-family:Verdana; > color:navy'>04/17/06</span></font><font size=2 color=navy face=Verdana><span >style='font-size:10.0pt;font-family:Verdana;color:navy'> rather than </span></font><font size=2 color=navy face=Verdana><span style='font-size:10.0pt;font-family:Verdana; > color:navy'>11:59:59 PM</span></font><font size=2 color=navy face=Verdana><span >style='font-size:10.0pt;font-family:Verdana;color:navy'> 04/16/06 and you are >running the script on </span></font><font size=2 color=navy face=Verdana><span > style='font-size:10.0pt;font-family:Verdana;color:navy'>04/17/06</span></fon t><font >size=2 color=navy face=Verdana><span style='font-size:10.0pt;font-family:Verdana; >color:navy'> then it will not include yesterday’s log as Windows says it >was modified today.</span></font></p> > ><p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size: >10.0pt;font-family:Verdana;color:navy'> </span></font></p> > ><p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size: >10.0pt;font-family:Verdana;color:navy'>FYI, I am doing this for IIS logs, KIWI >logs as well as Declude logs so I am looking for a universal solution.</span></font></p> > ><p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size: >10.0pt;font-family:Verdana;color:navy'> </span></font></p> > ><div> > ><p class=MsoNormal><strong><b><font size=1 color=navy face=Verdana><span >style='font-size:9.0pt;font-family:Verdana;color:navy'>John T</span></font></b></strong></p> > ><p class=MsoNormal><strong><b><font size=1 color=navy face=Verdana><span >style='font-size:9.0pt;font-family:Verdana;color:navy'>eServices For You</span></font></b></strong></p> > ><p class=MsoNormal><strong><b><font size=1 color=navy face=Verdana><span >style='font-size:9.0pt;font-family:Verdana;color:navy'> </span></font> </b></strong></p> > ><p class=MsoNormal><strong><b><font size=1 color=navy face=Verdana><span >style='font-size:8.0pt;font-family:Verdana;color:navy'>"Seek, and ye shall >find!"</span></font></b></strong></p> > ></div> > ><p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size: >10.0pt;font-family:Verdana;color:navy'> </span></font></p> > ><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'> > ><p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt; >font-family:Tahoma'>-----Original Message-----<br> ><b><span style='font-weight:bold'>From:</span></b> >[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] <b><span >style='font-weight:bold'>On Behalf Of </span></b>Dean Lawrence<br> ><b><span style='font-weight:bold'>Sent:</span></b> </span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>Monday, April > 17, 2006</span></font><font size=2 face=Tahoma><span style='font-size:10.0pt; >font-family:Tahoma'> </span></font><font size=2 face=Tahoma><span > style='font-size:10.0pt;font-family:Tahoma'>11:36 AM</span></font><font >size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'><br> ><b><span style='font-weight:bold'>To:</span></b> [email protected]<br> ><b><span style='font-weight:bold'>Subject:</span></b> Re: [Declude.JunkMail] >OT: Help with WinZip command line</span></font></p> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>John,</span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>I run the following 2 commands on my daily IIS log files.</span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>forfiles /p c:\clients /s /d -3 /m ex*.log /c "cmd /c wzzip >@fname.zip @file"</span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>forfiles /p c:\clients /s /d -3 /m ex*.log /c "cmd /c </span></font>del >@file"</p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>I keep each of my clients log files underneath their own client >directory so I use forfiles to identify the log files and zips anything that is >older than 3 day (so that I can review if something happened over the weekend). >I then run the same command, but using delete instead of wzzip. Both of these >commands are in a simple bat file that I call from windows scheduler. </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>Hope it helps,</span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'> </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>Dean</span></font></p> > ></div> > ><div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'><br> ><br> > </span></font></p> > ></div> > ><div> > ><p class=MsoNormal><span class=gmailquote><font size=3 face="Times New Roman"><span >style='font-size:12.0pt'>On </span></font></span><span > class=gmailquote>4/17/06</span><span class=gmailquote>, <b><span >style='font-weight:bold'>John T (Lists)</span></b> <<a >href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>> >wrote:</span> </p> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'>I am trying to create a batch file that will zip up a weeks worth of >logs<br> >and then move that zip file.<br> ><br> >The problem I am having is that I want to zip the previous 7 days, but<br> >sometimes the last log is time stamped say </span></font>04/16/06 11:59 PM and sometimes<br> >say 04/17/06 12:00 AM. Because of that, if I run the batch file on 04/17/06, <br> >it may or may not include the log file for 04/16/06 depending on the final<br> >time stamp.<br> ><br> >Other than stopping services just before midnight and then restarting, what<br> >is the best way to always ensure that I am processing the correct day's <br> >files?<br> ><br> >John T<br> >eServices For You<br> ><br> >"Seek, and ye shall find!"<br> ><br> ><br> ><br> >---<br> >This E-mail came from the Declude.JunkMail mailing list. To<br> >unsubscribe, just send an E-mail to <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>, >and<br> >type "unsubscribe Declude.JunkMail". The archives can be >found<br> >at <a href="http://www.mail-archive.com">http://www.mail-archive.com</a>.</p> > ></div> > ><p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size: >12.0pt'><br> ><br clear=all> ><br> >-- <br> >__________________________________________<br> >Dean Lawrence, CIO/Partner<br> >Internet Data Technology<br> >888.GET.IDT1 ext. 701 * fax: 888.438.4381<br> ><a href="http://www.idatatech.com/">http://www.idatatech.com/ </a><br> >Corporate Internet Development and Marketing Specialists </span></font></p> > ></div> > ></div> > ></body> > ></html> > --- This E-mail came from the Declude.JunkMail mailing list. To unsubscribe, just send an E-mail to [EMAIL PROTECTED], and type "unsubscribe Declude.JunkMail". The archives can be found at http://www.mail-archive.com.
