From: hackbard Date: Wed, 22 Jan 2003 17:07:28 +0000 (+0000) Subject: updated present script to 0.3-dev X-Git-Url: https://hackdaworld.org/gitweb/?p=scripts%2Fscripts.git;a=commitdiff_plain;h=57f23cb7c6f8e527220ea8a2aa2f21c41c1f6dea updated present script to 0.3-dev added logrotate.sh --- diff --git a/README b/README index bd262ee..1a3532f 100644 --- a/README +++ b/README @@ -6,4 +6,7 @@ - present_hdw_scripts.sh small script to copy the hdw-linux scripts on my http server +- logrotate.sh + rotate the log files (store and touch new one) + EOF diff --git a/logrotate.sh b/logrotate.sh new file mode 100755 index 0000000..d694981 --- /dev/null +++ b/logrotate.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# 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 }'` +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} + 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 +fi + diff --git a/present_hdw_scripts.sh b/present_hdw_scripts.sh index 745414e..5bc438e 100755 --- a/present_hdw_scripts.sh +++ b/present_hdw_scripts.sh @@ -3,7 +3,7 @@ # author: hackbard # -ver="0.2-dev" +ver="0.3-dev" inst_path="/chroot/www/htdocs/download/hdw-linux/hdw-linux-${ver}/scripts" echo "installing scripts to $inst_path ..."