]> hackdaworld.org Git - scripts/scripts.git/commitdiff
made logrotation more simple
authorhackbard <hackbard>
Fri, 19 Nov 2004 12:11:51 +0000 (12:11 +0000)
committerhackbard <hackbard>
Fri, 19 Nov 2004 12:11:51 +0000 (12:11 +0000)
logrotate.sh

index d694981785ff03ae6e6819878d36e345a8de37ac..b6bd553cd060bfad4bd748a4b317ff9e10d0b807 100755 (executable)
@@ -3,11 +3,10 @@
 # rotate the messages file if >= 4M
 
 if [ -f /var/log/messages ] ; then
-mess_size=`du -h /var/log/messages | sed 's/\/var\/log\/messages//' | sed 's/.*k/0/' | awk -F. '{ print $1 }'`
+mess_size=`du -h /var/log/messages | awk '{ print $1 }' | sed 's/.*k/0/' | awk -F. '{ print $1 }'`
 if [ "$mess_size" -gt "3" ] ; then
-       d_stamp=`date | awk '{ print $3 "-" $2 "-" $6 }'`
-       mv /var/log/messages /var/log/messages-${d_stamp}
-       gzip /var/log/messages-${d_stamp}
+       rm -f /var/log/messages.bz2
+       bzip2 /var/log/messages
        echo "rotated /var/log/messages file."
 fi
 fi
@@ -15,6 +14,7 @@ fi
 if [ ! -f /var/log/messages ] ; then
         touch /var/log/messages
         echo "touched new /var/log/messages file."
-       /etc/init.d/syslogd restart
+       /etc/init.d/sysklogd stop
+       /etc/init.d/sysklogd start
 fi