2020-02-10 03:25:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
while true; do
|
2020-05-07 22:38:03 +00:00
|
|
|
# Rotate logs
|
2020-02-10 03:25:47 +00:00
|
|
|
logrotate /etc/logrotate.conf
|
2020-05-07 22:38:03 +00:00
|
|
|
|
|
|
|
# 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
|
2020-02-10 03:25:47 +00:00
|
|
|
sleep 10m
|
|
|
|
done
|
|
|
|
|
|
|
|
# We should not exit
|
|
|
|
exit 1
|