##################### CPU ########################!/bin/bash### Execute it at 0:1 everynight.### Type "sh /tmp/script-shell/cpu.sh" in /etc/crontabvalue=`top -n 1 | awk 'NR==3 { print $2 }'`date=`date +%Y%m%d`if [ ! -d /tmp/script-shell ];then mkdir -p /tmp/script-shell else sleep 1s fiecho "Current time is `date`" >> /tmp/script-shell/$date.txtaaa=`date +%H`while [ $aaa -le 22 ]doecho "`date`" >> /tmp/script-shell/$date.txtecho "$value" >> /tmp/script-shell/$date.txtif[ $? = 0 ];thensleep 1selseecho "It's wrong"fisleep 30maaa=`date +%H`done##################### MEM ########################!/bin/bash ### Execute it at 0:1 everynight. ### Type "sh /tmp/script-shell/cpu.sh" in /etc/crontab ### Echo current free memory every 30 minutes date=`date +%Y%m%d` free=`free | awk 'NR==2 {print $4}'` buffers=`free | awk 'NR==2 {print $6}'` cached=`free | awk 'NR==2 {print $7}'` freemem=`expr $free + $buffers + $cached` if [ ! -d /tmp/script-shell ];then mkdir -p /tmp/script-shell else sleep 1s fi echo "$freemem" >> /tmp/script-shell/$date-mem.txt aaa=`date +%H` while [ $aaa -le 22 ] do echo "`date`" >> /tmp/script-shell/$date-mem.txt echo "$freemem" >> /tmp/script-shell/$date-mem.txt if [ $? = 0 ];then sleep 1s else echo "It's wrong" fi sleep 30m aaa=`date +%H` done
阅读(2401) | 评论(0) | 转发(0) |