From: hackbard Date: Fri, 19 Nov 2004 12:11:51 +0000 (+0000) Subject: made logrotation more simple X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8eb012e01ccb8f48275dea8c3b9998b2d45de8a;p=scripts%2Fscripts.git made logrotation more simple --- diff --git a/logrotate.sh b/logrotate.sh index d694981..b6bd553 100755 --- a/logrotate.sh +++ b/logrotate.sh @@ -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