Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have 4 servers (Windows 2003 R2), each with a log-directory with thousands of log-files. I have written a log-viewer that collect log-files within a date range and show them in a grid. But this is rather slow as the number of log-files grow fast.

If I could schedule to move all files older than N days to an zip-archive I think the logviewer should be much faster. I'm not good at write bat-files. Any suggestions ?

share|improve this question
1  
What type of logs? –  Zoredache Oct 29 '09 at 6:56
    
It is custom logs in textfiles for a server application written by our team. It as timestamp and a message, maybe an exception string etc. –  berocoder Nov 1 '09 at 17:45
add comment

1 Answer

up vote 1 down vote accepted

You should be able to use forfiles:

forfiles /m *.log /c <zip up here> /d -N

The /d switch tells forfiles to only consider files older than N days. Of course, you need to replace N with a nice number.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.