diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-10-28 02:03:26 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2006-10-28 02:03:26 +0000 |
commit | 4f7926f344ed54a298990b3dfcde520a3d8c8172 (patch) | |
tree | 149a8f332c4712ab626f3a2af2acdf3d0e2dbd43 | |
parent | 6c74b250180363c8ea170e821d6b5381e112537d (diff) |
Hardlink log files to log-for-stat
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@234 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-x | bin/weblogs-rotate | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/weblogs-rotate b/bin/weblogs-rotate index 594e0dc..874261e 100755 --- a/bin/weblogs-rotate +++ b/bin/weblogs-rotate @@ -17,20 +17,23 @@ end root = '/srv/www/vhosts/' archive_dir = "/logs-archive/" +forstats_dir = "/logs-for-stat/" logs_dir = "/logs/" Dir.chdir(root) today = Time.new.strftime("%Y-%m-%d"); Dir.glob("*").each{ |client| + root_logs_dir = root+"/"+client+logs_dir + root_archive_dir = root+"/"+client+archive_dir + root_forstats_dir = root+"/"+client+forstats_dir + Dir.chdir(root) next unless File.stat( client ).directory? 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 + next unless File.stat( root_logs_dir ).directory? + next unless File.stat( root_archive_dir ).directory? + next unless File.stat( root_forstats_dir ).directory? Dir.chdir(root_logs_dir) Dir.glob("*.log").each{ |filename| @@ -40,8 +43,10 @@ Dir.glob("*").each{ |client| File.exist?(root_archive_dir+targetname+".bz2") STDERR.puts("Not moving #{filename}: Target exists."); else + puts "Linking #{filename} to statsdir" if $VERBOSE + File.link( filename , root_forstats_dir+targetname ) puts "Moving #{filename}" if $VERBOSE - File.rename( filename , root_archive_dir+targetname ); + File.rename( filename , root_archive_dir+targetname ) end } } |