updated present script to 0.3-dev
authorhackbard <hackbard>
Wed, 22 Jan 2003 17:07:28 +0000 (17:07 +0000)
committerhackbard <hackbard>
Wed, 22 Jan 2003 17:07:28 +0000 (17:07 +0000)
added logrotate.sh

README
logrotate.sh [new file with mode: 0755]
present_hdw_scripts.sh

diff --git a/README b/README
index bd262ee..1a3532f 100644 (file)
--- a/README
+++ b/README
@@ -6,4 +6,7 @@
 - present_hdw_scripts.sh
   small script to copy the hdw-linux scripts on my http server
 
 - 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
 EOF
diff --git a/logrotate.sh b/logrotate.sh
new file mode 100755 (executable)
index 0000000..d694981
--- /dev/null
@@ -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
+
index 745414e..5bc438e 100755 (executable)
@@ -3,7 +3,7 @@
 # author: hackbard
 #
 
 # 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 ..."
 inst_path="/chroot/www/htdocs/download/hdw-linux/hdw-linux-${ver}/scripts"
 
 echo "installing scripts to $inst_path ..."