Merging logrotate'd files back again

As you may already know, logrotate is an excellent utility to keep the size of your log directory under certain control. However in some cases it may be feasible to „undo” the rotated logs into a single monolithic file. Such is a case when you want to migrate your web server log analization from webalizer to awstats. Fortunately there is an utility called mergelog that can this for you for a specific set of files. All I had to do was this small shell wrapper around mergelog to have a complete log directory (containing many virtual host logfiles from apache) „anti-logrotated” into the current working directory.

#!/bin/bash
 
if [ ! -d "$1" ]; then
        echo "usage: $0 [directory]"
        exit -1
fi
 
ls -1 "$1" | sed 's/[.]gz$//g' | sed 's/[.][0-9]*$//g' | sort | uniq | while read logname; do
 
        echo "merging files of ${logname}..."
        zmergelog "$1/${logname}"* > "${logname}"
 
done

Linkbacks

Use the following URL for manually sending trackbacks: http://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:merging_logrotate_d_files_back_again
en/blog/merging_logrotate_d_files_back_again.txt · Utolsó módosítás: 2009-09-05 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0