[logrotate] Enhance robustness (#2942)
* [logrotate] Decrease frequency to every 10 minutes; kill any lingering logrotate processes * [logrotate] Delete all *.1.gz files as firstaction; Remove note about init-system-helpers < 1.47 workaround However, continue to send SIGHUP directly to rsyslogd process because 'service rsyslog rotate' still doesn't work properly with init-system-helpers version 1.48
This commit is contained in:
parent
0f4cb41efc
commit
8ae67c4c5d
@ -1,2 +1,3 @@
|
||||
# Attempt to rotate system logs once per minute
|
||||
* * * * * root /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1
|
||||
# Attempt to rotate system logs once every 10 minutes.
|
||||
# First kill any logrotate process(es) if they are still running, as they're most likely hung
|
||||
*/10 * * * * root /usr/bin/pkill -9 logrotate > /dev/null 2>&1; /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1
|
||||
|
@ -19,11 +19,7 @@
|
||||
delaycompress
|
||||
sharedscripts
|
||||
postrotate
|
||||
# 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)
|
||||
/bin/kill -HUP $(cat /var/run/rsyslogd.pid)
|
||||
endscript
|
||||
}
|
||||
|
||||
@ -44,7 +40,7 @@
|
||||
compress
|
||||
delaycompress
|
||||
nosharedscripts
|
||||
prerotate
|
||||
firstaction
|
||||
# Adjust NUM_LOGS_TO_ROTATE to reflect number of log files that trigger this block specified above
|
||||
NUM_LOGS_TO_ROTATE=8
|
||||
|
||||
@ -65,6 +61,10 @@
|
||||
# of caution, giving us a bit of a cushion if a log grows quickly and passes its rotation size
|
||||
THRESHOLD_KB=$((USABLE_SPACE_KB - (NUM_LOGS_TO_ROTATE * LOG_FILE_ROTATE_SIZE_KB * 2)))
|
||||
|
||||
# First, delete any *.1.gz files that might be left around from a prior incomplete
|
||||
# logrotate execution, otherwise logrotate will fail to do its job
|
||||
find /var/log/ -name '*.1.gz' -type f -exec rm -f {} +
|
||||
|
||||
while true; do
|
||||
USED_KB=$(du -s /var/log | awk '{ print $1; }')
|
||||
|
||||
@ -87,11 +87,7 @@
|
||||
if [ $(echo $1 | grep -c "/var/log/swss/") -gt 0 ]; then
|
||||
pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true
|
||||
else
|
||||
# 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)
|
||||
/bin/kill -HUP $(cat /var/run/rsyslogd.pid)
|
||||
fi
|
||||
endscript
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user