Re: Sort logfiles at rotation time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Stephen Nelson-Smith wrote:

> I've had a look at the logrotate man page, and it looks like I can use
> a postrotate/endscript to do this.  However, I can see any reference
> in the documentation for how to operate on the file.  All the examples
> seem to take the form of restarting something, or running some other
> standalone script.  What I want to do is run a sort command against
> the newly rotated file - but how do I know what it is called?

How about this as an example -

"/home/user/var/log/httpd/*www*log" {
        daily
        rotate 1
        nocompress
        notifempty
        copytruncate
        missingok
        sharedscripts

        olddir /usr/local/log/httpd/archives

        postrotate
                DATE=`date --date=Yesterday +%y%m%d`
                cd /usr/local/log/httpd/archives
                for FOO in `ls *.1`
                do
                        mv $FOO `echo $FOO | cut -f1 -d.`.$DATE.log
                done
                gzip -9 *.$DATE.log
                sleep 60
                sync
                logger "[LOGROTATE] Rotated these logs: `echo
*.${DATE}.log.gz`"
        endscript

}

nate



_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux