Skip to content

Instantly share code, notes, and snippets.

@seanrclayton
Created September 24, 2015 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanrclayton/4a47f5da2ede19ad39a5 to your computer and use it in GitHub Desktop.
Save seanrclayton/4a47f5da2ede19ad39a5 to your computer and use it in GitHub Desktop.
Dir.glob('/var/local/project/logs/**').delete_if{|item| item.match(/\.gz/)}.each do |file|
if File.stat(file).size / 1048576 > 100
last_lines = IO.readlines(file).last(1000).join
File.open(file, 'w') {|f| f.write(last_lines); f.close}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment