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学习笔记
本文转自 Fanr_Zh 博客园博客,原文链接:http://www.cnblogs.com/Amaranthus/p/3754983.html
,如需转载请自行联系原作者