diff options
-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 } } |