From: hackbard Date: Thu, 6 Oct 2005 20:50:40 +0000 (+0000) Subject: use find to search for files +3M X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=9c08336da2cc4149fdea8d9fd58edaea87c130b2;p=scripts%2Fscripts.git use find to search for files +3M --- 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