diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-10-18 13:18:51 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2006-10-18 13:18:51 +0000 |
commit | 01f50c82edd57ba00497441276cc05d80435f10c (patch) | |
tree | 901be6674c6a94e5e06aabfe33077fdb5c4d21f2 | |
parent | 52c876fcb6f056b41494a0f5f5a46fe71d9648ea (diff) |
Move stuff to logs-archive
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@206 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-x | bin/weblogs-rotate | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/bin/weblogs-rotate b/bin/weblogs-rotate index 98e969f..594e0dc 100755 --- a/bin/weblogs-rotate +++ b/bin/weblogs-rotate @@ -15,28 +15,33 @@ ARGV.options do |opts| end -root = '/srv/www/vhosts' +root = '/srv/www/vhosts/' +archive_dir = "/logs-archive/" +logs_dir = "/logs/" + Dir.chdir(root) today = Time.new.strftime("%Y-%m-%d"); Dir.glob("*").each{ |client| Dir.chdir(root) next unless File.stat( client ).directory? - next unless File.exist?( client + "/logs" ) - next unless File.stat( client + "/logs" ).directory? - - logroot = root+"/"+client+"/logs" - Dir.chdir(logroot) + next unless File.exist?( client + logs_dir ) + next unless File.stat( client + logs_dir ).directory? + next unless File.stat( client + archive_dir ).directory? + + root_logs_dir = root+"/"+client+logs_dir + root_archive_dir = root+"/"+client+archive_dir + + Dir.chdir(root_logs_dir) Dir.glob("*.log").each{ |filename| targetname = filename +"."+ today - - if File.exist?(targetname) or - File.exist?(targetname+".gz") or - File.exist?(targetname+".bz2") + if File.exist?(root_archive_dir+targetname) or + File.exist?(root_archive_dir+targetname+".gz") or + File.exist?(root_archive_dir+targetname+".bz2") STDERR.puts("Not moving #{filename}: Target exists."); else puts "Moving #{filename}" if $VERBOSE - File.rename( filename , targetname ); + File.rename( filename , root_archive_dir+targetname ); end } } |