From 4f7926f344ed54a298990b3dfcde520a3d8c8172 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 28 Oct 2006 02:03:26 +0000 Subject: Hardlink log files to log-for-stat git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@234 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- bin/weblogs-rotate | 17 +++++++++++------ 1 file 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 } } -- cgit v1.2.3