From 9c08336da2cc4149fdea8d9fd58edaea87c130b2 Mon Sep 17 00:00:00 2001 From: hackbard Date: Thu, 6 Oct 2005 20:50:40 +0000 Subject: [PATCH] use find to search for files +3M --- logrotate.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/logrotate.sh b/logrotate.sh index 9938c80..b97a9d8 100755 --- a/logrotate.sh +++ b/logrotate.sh @@ -4,17 +4,13 @@ dodel=0 -for i in /var/log/messages /var/log/sys.log /var/opt/apache2/logs/access_log /var/opt/apache2/logs/error_log; do - if [ -f $i ] ; then - mess_size=`du -h $i | awk '{ print $1 }' | sed 's/.*k/0/' | awk -F. '{ print $1 }'` - if [ "$mess_size" -gt "3" ] ; then +logpaths="/var/log /var/opt/apache2/logs" +for i in `find $logpaths -size +3M`; do rm -f ${i}.bz2 bzip2 $i echo "rotated $i file, touching empty file." [ ! -f $i ] && touch $i dodel=1 - fi - fi done if [ "$dodel" = "1" ] ; then -- 2.39.2