How to split and compress apache log with logrotate
Open the httpd log rotate script on /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
Change the script to following script
/var/log/httpd/*log {
daily
rotate 365
missingok
notifempty
dateext
compress
compresscmd /usr/bin/bzip2
compressext .bz2
copytruncate
sharedscripts
}
You can testing the script directly using following command
logrotate -df /etc/logrotate.d/httpd
You can execute the script directly using following command
logrotate -f /etc/logrotate.d/httpd