Skip to main content

Logrotate

Install Logrotate

dnf install -y logrotate

Nginx Logrotate

/home/wwwlogs/*/access.log /home/wwwlogs/*/error.log {
monthly
rotate 6
compress
delaycompress
missingok
notifempty
create 0640 www www
sharedscripts
postrotate
systemctl reload nginx > /dev/null 2>&1
endscript
}

Modsecurity Logrotate

/var/log/modsec_audit.log {
daily
rotate 10
compress
delaycompress
missingok
notifempty
create 0640 root root
sharedscripts
copytruncate
}

Useful Commands

# Test a configuration file
logrotate -d /etc/logrotate.d/nginx
# View service timer
less /var/lib/logrotate/logrotate.status
# View built-in services
ls /etc/logrotate.d/