]> hackdaworld.org Git - scripts/scripts.git/commitdiff
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 bd262ee4333914007fb3c421008ac8864e0fca4d..1a3532f0279ddbf68122ab9e846414a531e81b1b 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
 
+- logrotate.sh
+  rotate the log files (store and touch new one)
+
 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 745414e90550beea6f4790898fff869901c6a586..5bc438ee6062ab0dc7f60ba6ad14fb57d70289d4 100755 (executable)
@@ -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 ..."