From a8eb012e01ccb8f48275dea8c3b9998b2d45de8a Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 19 Nov 2004 12:11:51 +0000 Subject: [PATCH] made logrotation more simple --- logrotate.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 -- 2.39.2