From f28790ce9a1d9416df21c38bd07f3512e674c046 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Mon, 24 Apr 2017 17:55:05 -0700 Subject: [PATCH] [System logs]: Fix logrotate bugs (#535) - rsyslog logs were being rotated regardless of whether they exceeded their maixmum size. This was due to "-f" flag passed to logrotate in cron job. - After rotation, /var/log/syslog was never written to again. Instead, logs were written to /var/log/syslog.1. This was due to rsyslog not properly closing the file descriptor to the pre-rotated log. - Also brought back time-related rotation via the new(er) maxsize option, which performs a boolean OR operation. If the log exceeds the maxsize OR the log hasn't been rotated in the specified, it will be rotated. Using the older size option, the time-based rotation was ignored. - Also addresses issue #528 --- files/image_config/cron.d/logrotate | 2 +- files/image_config/logrotate.d/rsyslog | 20 +++++++++++++------- files/image_config/systemd/journald.conf | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/files/image_config/cron.d/logrotate b/files/image_config/cron.d/logrotate index e7813aa1f5..877e0cb6d5 100644 --- a/files/image_config/cron.d/logrotate +++ b/files/image_config/cron.d/logrotate @@ -1,3 +1,3 @@ # Attempt to rotate system logs once per minute -* * * * * root /usr/sbin/logrotate -f /etc/logrotate.d/rsyslog +* * * * * root /usr/sbin/logrotate /etc/logrotate.d/rsyslog diff --git a/files/image_config/logrotate.d/rsyslog b/files/image_config/logrotate.d/rsyslog index c09604187f..0d03e906c9 100644 --- a/files/image_config/logrotate.d/rsyslog +++ b/files/image_config/logrotate.d/rsyslog @@ -3,16 +3,18 @@ /var/log/teamd.log { rotate 7 -# Removed 'daily' interval, as we now call logrotate more frequently via cron -# and we want to check these logs every time -# daily - size 100M + daily + maxsize 100M missingok notifempty compress delaycompress postrotate - invoke-rc.d rsyslog rotate > /dev/null + # Calling kill directly instead of 'service rsyslog rotate >/dev/null' due + # to bug in init-system-helpers. Bug has apparently been fixed in v1.47. + # However, Debian Jessie is still using v1.22. + # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672218 + kill -HUP $(cat /var/run/rsyslogd.pid) endscript } /var/log/mail.info @@ -30,14 +32,18 @@ { rotate 4 weekly - size 100M + maxsize 100M missingok notifempty compress delaycompress sharedscripts postrotate - invoke-rc.d rsyslog rotate > /dev/null + # Calling kill directly instead of 'service rsyslog rotate >/dev/null' due + # to bug in init-system-helpers. Bug has apparently been fixed in v1.47. + # However, Debian Jessie is still using v1.22. + # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672218 + kill -HUP $(cat /var/run/rsyslogd.pid) endscript } diff --git a/files/image_config/systemd/journald.conf b/files/image_config/systemd/journald.conf index fc6c4a4e7a..c32fbae570 100644 --- a/files/image_config/systemd/journald.conf +++ b/files/image_config/systemd/journald.conf @@ -15,10 +15,10 @@ #SyncIntervalSec=5m #RateLimitInterval=30s #RateLimitBurst=1000 -SystemMaxUse=50MB +SystemMaxUse=50M #SystemKeepFree= #SystemMaxFileSize= -RuntimeMaxUse=50MB +RuntimeMaxUse=50M #RuntimeKeepFree= #RuntimeMaxFileSize= #MaxRetentionSec=