]> hackdaworld.org Git - scripts/scripts.git/commitdiff
use find to search for files +3M
authorhackbard <hackbard>
Thu, 6 Oct 2005 20:50:40 +0000 (20:50 +0000)
committerhackbard <hackbard>
Thu, 6 Oct 2005 20:50:40 +0000 (20:50 +0000)
logrotate.sh

index 9938c80c0e52c124d5117080b07a97e098b2d684..b97a9d8e831e74bc87073dab0f47128c713ac02b 100755 (executable)
@@ -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