Log Rotate
Jump to navigation
Jump to search
Introduction
Log Rotation is an automated process used in system administration in which log files are compressed, moved, renamed or deleted once they are too old or too big. New incoming log data is directed into a new fresh file.
Installation
yum update && yum install logrotate
Configuration
- Edit the httpd log rotate conf file.
vim /etc/logrotate.d/httpd
- Delete all default lines and replace with these lines
/var/log/httpd/*log {
monthly
rotate 3
size=10M
compress
missingok
notifempty
dateext
dateformat -%m%d%Y
sharedscripts
postrotate
/root/scp_logs.sh
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
/var/log/httpd/*/*log {
monthly
rotate 3
size=10M
compress
missingok
notifempty
dateext
dateformat -%m%d%Y
sharedscripts
postrotate
/root/scp_logs.sh
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}