Shell scripting
Table of contents
Archive dmesg on reboot
This small script will log dmesg on booting and tail 100 lines of messages on shutdown.Preparing directory
mkdir /root/dmesg-archive
Put the following in /usr/local/etc/rc.d/dmesg-archive.sh and chmod 755 it.
#!/bin/sh
DATE=`/bin/date "+%Y-%m_%H-%M-%S"`
case "\$1" in
start)
/sbin/dmesg > /root/dmesg-archive/dmesg_$DATE
;;
stop)
/usr/bin/tail -100 /var/log/messages > /root/dmesg-archive/messages_$DATE
;;
*)
echo ""
echo "Usage: `basename \$0` { start | stop }"
echo ""
exit 1
;;
esac- + : A leading plus sign indicates that this word must be present in every object returned.
- - : A leading minus sign indicates that this word must not be present in any row returned.
- By default (when neither plus nor minus is specified) the word is optional, but the object that contain it will be rated higher.
- < > : These two operators are used to change a word's contribution to the relevance value that is assigned to a row.
- ( ) : Parentheses are used to group words into subexpressions.
- ~ : A leading tilde acts as a negation operator, causing the word's contribution to the object relevance to be negative. It's useful for marking noise words. An object that contains such a word will be rated lower than others, but will not be excluded altogether, as it would be with the - operator.
- * : An asterisk is the truncation operator. Unlike the other operators, it should be appended to the word, not prepended.
- " : The phrase, that is enclosed in double quotes ", matches only objects that contain this phrase literally, as it was typed.
