mynode/rootfs/standard/usr/bin/mynode_logrotate.sh
2020-05-07 17:38:03 -05:00

24 lines
478 B
Bash
Executable File

#!/bin/bash
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
# We should not exit
exit 1