GZip IIS logs in four lines of ruby
Posted by Sam
I've been running IIS web servers for about 8 years now. I have to say that I'm not a big fan. It's more of a hassle to move and automate, especially compared to Apache. One of the things I haven't taken time to really take care of until now is managing the logs in an automated fashion. I decided it was time to take 5 minutes to handle this repetitive task. So I took a couple of minutes and installed Ruby 1.8.6 on the web servers and wrote the four line script to find and gzip all IIS log files excluding todays. Hopefully you find it useful.
ignore_file = Time.now.strftime 'ex%y%m%d.log'
Dir.glob 'C:/logs/**/*.log' do |f|
`c:/scripts/gzip.exe -9 #{f}` unless f.include? ignore_file
end