Die Standard logrotate.conf rotiert die logfiles wöchentlich und hebt die Logs 52 Wochen auf. Für mich reicht es, die Logs nur 3 Tage aufzuheben, ausserdem habe ich deren Größe auf 2MB begrenzt, was bei einer Ramdisk ja durchaus Sinn macht.
Hier meine derzeitige logrotate.conf:
Code:
# rotate log files daily
daily
# keep 3 days worth of backlogs
rotate 3
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
compress
size=2M
# wtmp
/var/log/wtmp {
weekly
create 0664 root utmp
rotate 1
}
/var/log/httpd/access_log /var/log/httpd/error_log /var/log/httpd/ssl_request_log /var/log/httpd/ssl_engine_log {
missingok
sharedscripts
size=2M
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}
/var/log/snort/alert {
weekly
copytruncate
compress
ifempty
missingok
postrotate
/usr/bin/find /var/log/snort -path '/var/log/snort/[0-9]*' -prune -exec /bin/rm -rf {} \;
/usr/bin/find /var/log/snort -name 'snort.log.*' -mtime +28 -exec /bin/rm -rf {} \;
/usr/local/bin/restartsnort
endscript
}
/var/log/squid/access.log /var/log/squid/user_agent.log /var/log/squid/referer.log {
weekly
copytruncate
ifempty
missingok
}
/var/log/squid/cache.log {
weekly
rotate 3
copytruncate
compress
missingok
}
/var/log/squid/store.log {
weekly
rotate 3
copytruncate
compress
missingok
postrotate
/bin/chmod -R ugo+rX /var/log/squid
/usr/sbin/squid -k rotate
endscript
}
/var/log/messages /var/log/boot.log /var/log/dhcpcd.log {
create 664 root syslogd
sharedscripts
size=2M
ifempty
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
Weiterhin sichere ich die logs nur noch einmal pro Woche auf die CF-Karte (und natürlich beim shutdown). Die ersten Zeilen meiner fcrontab lauten daher:
Code:
# Log rotation
01 * * * * /usr/sbin/logrotate /etc/logrotate.conf
# Backup logs to flashdisk (only sunday at 03:00)
0 3 7 * * [ -f "/etc/FLASH" ] && /etc/rc.d/rc.flash.down
Mitunter kommt es vor, dass die Zeile
Code:
# Backup logs to flashdisk
...
mehrfach in der fcrontab vorkommt, dadurch werden die logs unnötigerweise auch mehrfach auf die CF-Karte geschrieben. Falls das bei Dir auch der Fall ist, kannst Du diese Zeilen löschen, nur den ersten Eintrag am Anfang der Datei erhalten.