What
Logrotate : rotation and compression of system log filesWhy I need it
You will realize that your log files are endlessly growing and you need to manage them in more elegant way.Where to get it and how to install it
I like to take it from Blastwave using pkg-get. Check available package:
# pkg-get -a | grep logrotate logrotate 3.7.4,REV=2007.01.16 |
# pkg-get -i logrotate |
# pkginfo |grep logrotate application CSWlogrotate logrotate - rotates, compresses, and mails system logs |
# pkginfo -l CSWlogrotate PKGINST: CSWlogrotate NAME: logrotate - rotates, compresses, and mails system logs CATEGORY: application ARCH: sparc VERSION: 3.7.4,REV=2007.01.16 BASEDIR: / VENDOR: http://download.fedora.redhat.com/pub/fedora/linux/core/development/SRPMS/ packaged for CSW by Frederic Van De Vede PSTAMP: ra20070116145115 INSTDATE: Jul 02 2009 19:45 HOTLINE: http://www.blastwave.org/bugtrack/ EMAIL: fred@blastwave.org STATUS: completely installed FILES: 14 installed pathnames 7 shared pathnames 9 directories 1 executables 165 blocks used (approx) |
# crontab -l # logrotate for syslog-ng 0 0 * * * /opt/csw/bin/logrotate -f -s /logs/hosts/.logrotate.status /etc/csw/logrotate.conf.hosts 0 0 * * * /opt/csw/bin/logrotate -f -s /logs/services/.logrotate.status /etc/csw/logrotate.conf.services |
#cat /etc/csw/logrotate.conf.hosts # Global options: # Compress old log files compress # Use this compress command compresscmd /usr/bin/gzip # Rotate log files every day daily # It's okay if logfile is missing, maybe host doesn't log every day missingok # Move rotated files here olddir /logs/hosts/.archive # Rotate files for 90 days and them remove them, so keep them 3 months rotate 90 # Start rotated extension with 0 start 0 # Does three actions below after all log files are rotated and if at least one log file is rotated /logs/hosts/*:*log { lastaction /usr/sbin/svcadm refresh svc:/system/syslog-ng:default logger -p user.info -t logrotate "log file rotated" logger -p mail.info -t logrotate "log file rotated" endscript } |