Skip to content

Instantly share code, notes, and snippets.

@jamesu
Created February 4, 2012 15:32
Show Gist options
  • Save jamesu/1738512 to your computer and use it in GitHub Desktop.
Save jamesu/1738512 to your computer and use it in GitHub Desktop.
Consolidate nginx server logs
#!/usr/bin/ruby
# usage: nginx_consolidate.rb /var/log/nginx/*log*
#
require 'zlib'
ARGV.sort.each do |file|
if File.extname(file) == ".gz"
Zlib::GzipReader.open(file) { |f| STDOUT.write f.read }
else
File.open(file) { |f| STDOUT.write f.read }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment