Fanr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
echo 192.168.10.69>>ip.list
-------------------------------------------
#!/bin/bash
#注意if和[]之间的空格
rm -f ~/fanr/shell/DiskUsageAlert/out.print
out=$(cat ~/fanr/shell/DiskUsageAlert/ip.list)

echo $out
for _IP in $out
do
        ssh root@$_IP df | grep -vE "none|devfs"|awk '{if(NR>=2 && int($5)>100) print "'$_IP'" ":disk at " $6 " usage is "$5 " large than 90%" }' >> ~/fanr/shell/DiskUsageAlert/out.print

done

print=$(cat ~/fanr/shell/DiskUsageAlert/out.print)

echo $print
if [ "$print" != "" ]
#if[ -s "~/fanr/shell/DiskUsageAlert/out.print" ]
then
        echo 11
        #echo $print| mail -s"Disk Usage Alerter" fai@tgn.com
fi
--------------------------------------------------------------------------------------
crontab DiskUsageAlert.crontab
cat DiskUsageAlert.crontab
#每5分钟运行一次
*/5 * * * * sh /root/fanr/shell/DiskUsageAlert/DiskUsageAlter.sh
参考:
http://liguxk.blog.51cto.com/129038/123555 linux 自动执行 crontab学习笔记
posted on 2014-05-27 14:01  Fanr_Zh  阅读(416)  评论(0编辑  收藏  举报