From af95dc7d2215f16b0fd9ee0010b9bdec79956aa2 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Thu, 7 May 2020 17:38:03 -0500 Subject: [PATCH] Prevent some logs from growing forever --- rootfs/standard/usr/bin/mynode_logrotate.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rootfs/standard/usr/bin/mynode_logrotate.sh b/rootfs/standard/usr/bin/mynode_logrotate.sh index 646da66e..b8f8a320 100755 --- a/rootfs/standard/usr/bin/mynode_logrotate.sh +++ b/rootfs/standard/usr/bin/mynode_logrotate.sh @@ -4,7 +4,18 @@ set -e set -x while true; do + # Rotate logs 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 done