Prevent some logs from growing forever

This commit is contained in:
Taylor Helsper 2020-05-07 17:38:03 -05:00
parent 3c81c93f20
commit af95dc7d22

View File

@ -4,7 +4,18 @@ set -e
set -x set -x
while true; do while true; do
# Rotate logs
logrotate /etc/logrotate.conf logrotate /etc/logrotate.conf
# Check for any "lost" logs that are growing too large
LARGE_FILE_COUNT=$(find /var/log/ -type f -size +10M | wc -l)
if [ "$LARGE_FILE_COUNT" -gt "0" ]; then
# Delete the files and restart syslog
find /var/log/ -type f -size +10M | sudo xargs rm -f
systemctl restart syslog
fi
# Sleep
sleep 10m sleep 10m
done done