From 019e4b32db037945d480ba667357388dac8fcec3 Mon Sep 17 00:00:00 2001 From: Gardais Jeremy Date: Tue, 5 Sep 2017 17:04:52 +0200 Subject: [PATCH] Set a new logrotate config (#12). --- scripts/latecommand/logrotate/aptitude | 12 +- scripts/latecommand/logrotate/dpkg | 33 +++-- scripts/latecommand/logrotate/logrotate.conf | 27 +++-- scripts/latecommand/logrotate/rsyslog | 121 ++++++++++++------- scripts/latecommand/post.sh | 5 +- 5 files changed, 116 insertions(+), 82 deletions(-) diff --git a/scripts/latecommand/logrotate/aptitude b/scripts/latecommand/logrotate/aptitude index 25cbff8..541ce77 100644 --- a/scripts/latecommand/logrotate/aptitude +++ b/scripts/latecommand/logrotate/aptitude @@ -1,8 +1,8 @@ /var/log/aptitude { - rotate 6 - weekly - compress - missingok - notifempty - olddir /var/log/old_logs + rotate 6 + monthly + compress + missingok + notifempty + olddir /var/log/aptitude.d } diff --git a/scripts/latecommand/logrotate/dpkg b/scripts/latecommand/logrotate/dpkg index 933457d..4b39ff8 100644 --- a/scripts/latecommand/logrotate/dpkg +++ b/scripts/latecommand/logrotate/dpkg @@ -1,22 +1,21 @@ /var/log/dpkg.log { - weekly - rotate 12 - compress - delaycompress - missingok - notifempty - create 644 root root - olddir /var/log/old_logs + monthly + rotate 12 + compress + delaycompress + missingok + notifempty + create 644 root root + olddir /var/log/dpkg } /var/log/alternatives.log { - weekly - rotate 12 - compress - delaycompress - missingok - notifempty - create 644 root root - olddir /var/log/old_logs + monthly + rotate 12 + compress + delaycompress + missingok + notifempty + create 644 root root + olddir /var/log/alternatives } - diff --git a/scripts/latecommand/logrotate/logrotate.conf b/scripts/latecommand/logrotate/logrotate.conf index 446156b..5b00ccd 100644 --- a/scripts/latecommand/logrotate/logrotate.conf +++ b/scripts/latecommand/logrotate/logrotate.conf @@ -8,7 +8,7 @@ rotate 4 # create new (empty) log files after rotating old ones create -# uncomment this if you want your log files compressed +# old versions of log files are compressed with gzip compress # compress only from the second log file @@ -17,26 +17,27 @@ delaycompress # use date as a suffix of the rotated file dateext +# do not rotate the log if it is empty +notifempty + # packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp, or btmp -- we'll rotate them here /var/log/wtmp { - missingok - notifempty - monthly - create 0664 root utmp - olddir /var/log/old_logs - rotate 3 + rotate 3 + monthly + missingok + create 0664 root utmp + olddir /var/log/old_logs } /var/log/btmp { - missingok - notifempty - monthly - create 0664 root utmp - olddir /var/log/old_logs - rotate 3 + monthly + rotate 3 + missingok + create 0660 root utmp + olddir /var/log/old_logs } # system-specific logs may be configured here diff --git a/scripts/latecommand/logrotate/rsyslog b/scripts/latecommand/logrotate/rsyslog index a1c5859..09c1331 100644 --- a/scripts/latecommand/logrotate/rsyslog +++ b/scripts/latecommand/logrotate/rsyslog @@ -1,20 +1,7 @@ -# Ensure to rotate all log files (old and new logpath from Rsyslog) +# Default directives are activilly used, please see /etc/logrotate.conf -/var/log/syslog/syslog -/var/log/syslog/syslog.log -/var/log/syslog/daemon.log -/var/log/syslog/local0.log -/var/log/syslog/local1.log -/var/log/syslog/local2.log -/var/log/syslog/local3.log -/var/log/syslog/local4.log -/var/log/syslog/local5.log -/var/log/syslog/local6.log -/var/log/syslog/local7.log -/var/log/syslog/uucp.log /var/log/syslog /var/log/syslog.log -/var/log/daemon.log /var/log/local0.log /var/log/local1.log /var/log/local2.log @@ -25,52 +12,96 @@ /var/log/local7.log /var/log/uucp.log { - rotate 7 - daily - missingok - notifempty - compress - delaycompress - postrotate - invoke-rc.d rsyslog rotate > /dev/null - endscript + rotate 7 + daily + missingok + olddir /var/log/syslog.d + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript } -/var/log/cron/cron.log -/var/log/cron/mark.log -/var/log/kernel/kern.log -/var/log/kernel/kernel.log -/var/log/lpr/lpr.log -/var/log/mail/*.log -/var/log/security/auth.log -/var/log/security/authpriv.log -/var/log/security/user.log -/var/log/messages/messages -/var/log/news/news.log /var/log/cron.log /var/log/mark.log +{ + maxsize 250k + missingok + sharedscripts + olddir /var/log/cron + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + +/var/log/daemon.log +{ + maxsize 250k + missingok + sharedscripts + olddir /var/log/daemon + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + /var/log/kern.log /var/log/kernel.log +{ + maxsize 250k + missingok + sharedscripts + olddir /var/log/kern + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + /var/log/lpr.log +{ + maxsize 250k + missingok + sharedscripts + olddir /var/log/lpr + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + /var/log/mail.log /var/log/mail.info /var/log/mail.warn /var/log/mail.err +{ + maxsize 250k + missingok + sharedscripts + olddir /var/log/mail + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + /var/log/auth.log /var/log/authpriv.log /var/log/user.log +{ + maxsize 250k + missingok + sharedscripts + olddir /var/log/auth + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + /var/log/messages /var/log/debug { - rotate 4 - maxsize 250k - weekly - missingok - notifempty - compress - delaycompress - sharedscripts - postrotate - invoke-rc.d rsyslog rotate > /dev/null - endscript + maxsize 250k + missingok + sharedscripts + olddir /var/log/messages.d + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript } diff --git a/scripts/latecommand/post.sh b/scripts/latecommand/post.sh index a36d927..b3782e9 100755 --- a/scripts/latecommand/post.sh +++ b/scripts/latecommand/post.sh @@ -46,7 +46,10 @@ cp "${LOGROTATE_APTITUDE_CONF}" "${LOGROTATE_APTITUDE_FILE}" cp "${LOGROTATE_DPKG_CONF}" "${LOGROTATE_DPKG_FILE}" # Create an archive directory for some log files (aptitude, dpkg,…) -mkdir -p -- /var/log/old_logs +mkdir -p -- /var/log/old_logs /vaar/log/aptitude.d /var/log/dpkg /var/log/alternatives /var/log/syslog.d /var/log/cron /var/log/daemon /var/log/kern /var/log/lpr /var/log/mail /var/log/auth /var/log/messages + +chmod 0750 /var/log/auth /var/log/daemon /var/log/kern /var/log/messages /var/log/syslog.d +chown root:adm /var/log/auth /var/log/daemon /var/log/kern /var/log/messages /var/log/syslog.d # Create the log directory for journald (Systemd), need the configuration Storage=(auto|persistent) mkdir -p -- /var/log/journal