enjoylife's Stuff

Home » enjoylife (2 trails)
enjoylife's Stats (public trails only):
Trails created: 80
Marks created: 1246
Views received: 100,713
Positive ratings: 1
Negative ratings:
Comments received: 3
Comments left: 0
super master (enjoylife)

enjoylife's Trails: grep    (view all)

first, make a script, like /root/check_temp.sh:

#!/bin/sh
TEMP_A=`/usr/sbin/smartctl -d ata -A /dev/sda | grep Temperature | cut -d ' ' -f37`
TEMP_B=`/usr/sbin/smartctl -d ata -A /dev/sdb | grep Temperature | cut -d ' ' -f37`
THRESHOLD=65

#In case Temp B doesn't return a reading (You only have one drive)
if [ "$TEMP_B" = "" ] ; then
 TEMP_B=0
fi

#Check to make sure it's not running too hot
if [ $TEMP_A -gt $THRESHOLD ] || [ $TEMP_B -gt $THRESHOLD ] ; then
 logger -s "One of the drives has exceeded the threshold of $THRESHOLD degrees C."
 poweroff
fi

make it executable: chmod 755 check_temp.sh

edit root's crontab (/etc/crontabs/root) to include this script. This one will run the script every fifteen minutes:

# standard crontab format for busybox cron daemon.
# fields may be lists
# min    hour day month wd  command
#  *      *    *   *     *   dosomething

# save the time every 60 minutes use 7 minute past the hour.
7   *    *   *     *   date +%m%d%H%M%Y.%S > /var/lib/now
0,15,30,45 * * * * /root/check_temp.sh

Then, either reboot the box, or restart cron: /etc/init.d/crond.sh stop, etc/init.d/crond.sh start

Tags: smartctl, root, cron, grep, temp, ...
A trail of 2 pages
The C-shell offers a number of special commands known as control codes. Control codes define commands specific to the operating system. To issue a control code, hold down and press the corresponding letter key. The following summarizes some of the most commonly used control codes:
 d Signals the end of a file you are entering from the terminal if typed at the beginning of a line or if typed twice elsewhere in a line.
 c Cancels a command or interrupts a running program.
 z Suspends a process or job but does not terminate it: use fg to restart suspended process or job.
common_alias myscreen '~/bin/screen'
common_alias ls   'ls --color=auto'


common_alias findfile    'find . -follow -type f | grep $*'
common_alias findtext 'find . -not -name "*.d" -not -name "*.o" -not -name "*.a" -follow -type f -print0 | xargs --null grep $*'
#common_alias findcode    "find -follow -type f -name '*.cpp' -o -name '*.h' -o -name '*.java' -o -name '*.const' -print0| xargs --null grep $*"
common_alias findcode 'find . -name "*.cpp" -name "*.h" -name "*.java" -name "*.c" -name "*.hpp" -follow -type f -print0 | xargs --null grep $*'
common_alias findcdb 'find . -name "*.layout" -name "*.def" -name "*.cdb" -follow -type f -print0 | xargs --null grep $*'
common_alias findweb 'find . -name "*.aml" -name "*.xml" -name "*.xsd" -name "*.mdl" -name "*.sml" -follow -type f -print0 | xargs --null grep $*'
common_alias findany 'find . -follow -type f -print0 | xargs --null grep $*'

 

export PS1="\h@\u:\w% "
export DISPLAY=l-sjn-jezhao:0.0
export LS_COLORS='di=01;33'

function cleanup(){
        echo "Removing $1 files..."
        find \. -follow -name "$1" | xargs rm
u Clears the command line.




Tags: grep, alias, xargs, name, findcode, ...
A trail of 44 pages