====== Log Rotate ====== **General Information** * The package "logrotate" is installed by default on most linux distros. * Logrotate is executed via a daily cron job: /etc/cron.daily/logrotate **Checklist** * Distro(s): Enterprise Linux 6 ---- ===== Force Rotation ===== Forcing a log rotation can be useful after implementing a new rotation file (in /etc/logrotate.d) or to test after making changes. * To force a logrotate using a specific config file * /usr/sbin/logrotate -f /etc/logrotate.d/myapp * To force a logrotate of ALL log files * /usr/sbin/logrotate -f /etc/logrotate.conf ---- ===== /etc/logrotate.conf ===== /etc/logrotate.conf is left alone in its default installed state. Ensure that /etc/logrotate.d is included (it is by default): include /etc/logrotate.d ---- ===== /etc/logrotate.d/ ===== All additional log configuration files go in: /etc/logrotate.d/ Example Log Config ## Application Logs ## /opt/myapp/logs/logs.txt { #Rotate monthly monthly #Keep 12 old log files, delete older rotate 12 #Copy current log to rotated, then truncate in place copytruncate #Give rotated log file a date extension YYYYMMDD dateext #Compress old log files with gzip compress } ----