监控服务器是否宕机的脚本:$ sudo vi ping.sh按a或i进入编辑模式#!/bin/bashDate=`date +%m%d%y`touch /log/Ping/$Date.logServer="ming1 ming2 ming3 ming4 ming5"for Server in $ServerdoPing=`/bin/ping -c 4 $Server | grep % | awk -F[:" "]+ '{print $6}' | tr -d '%'`Ping2=`/bin/ping -c 4 $Server | grep % | awk -F[:" "]+ '{print $8}' | tr -d '%'`if [ $Ping -eq "0" ]thenecho "$Server is ok" >> /log/Ping/$Date.logelif [ $Ping2 -eq "100" ]thenecho "$Server is down" >> /log/Ping/$Date.logfidone/usr/bin/mail -s "Android Server Status" zhi.yang@spreadtrum.com < /log/Ping/$Date.log按Esc键退出编辑模式:wq (保存并退出)