DailyLogRotation

From rsyslog wiki
Jump to: navigation, search

A solution to rotate logs on a daily basis is to use dynamic files and after a while rotate the log files away. Quick sample:

/etc/rsyslog.conf:

#####################################################
# Log everything to a per host daily logfile        #
#####################################################
$template DailyPerHostLogs,"/var/log/syslog/%$YEAR%/%$MONTH%/%$DAY%/%HOSTNAME%/messages.log"
*.* -?DailyPerHostLogs

/etc/cron.hourly/syslog-bzip2:

# Compress *.log-files not changed in more than 24 hours:
find /var/log/syslog/2008 -type f -mtime +1  -name "*.log" -exec bzip2 '{}' \;
Personal tools
language