# 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
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