上一篇: rsync结合find技巧
#!/bin/bash
load=`uptime`
shijian=`date +%Y-%m-%d-%T`
file=cpustatus.txt
touch $file
all=`cat $file |wc -l`
printf "$load $shijian\n" >> $file
if [[ $all > 60 ]] ; then
starttime=`cat $file |awk '{print $13}'|sort -r|tail -1`
stoptime=`cat $file |awk '{print $13}'|sort -n|tail -1`
loadavg=`cat $file |awk '{avg1+=$10;avg2+=$11;avg3+=$12}END{print avg1/NR,avg2/NR,avg3/NR}'`
high=`cat $file |awk '{print $10}'|sort -n|tail -1`
low=`cat $file |awk '{print $10}'|sort -r|tail -1`
printf "$starttime \n load average $loadavg \n high $high \n low $low \n $stoptime \n\n" > j
#printf "load average $startus \n" >>j
#mv $f $f.$b
fi
在配合 Crontab
linux crontab命令
Crontab 实例(转)
邮件转发
linux下发送邮件..