零零碎碎写的脚本(四)自动监控某系统服务状态并警报

#!/bin/bash
#author by sysk

read -p "Plese input service:" SERVICE
   service $SERVICE status &>/dev/null
        STATUS=$?

while [ $STATUS -eq 0 ]; do
   echo "`date`,$SERVICE is runing..."
   sleep 5
   service $SERVICE status &>/dev/null
   STATUS=$?
done

echo "$SERVICE is STOP!!!" && mail -s 'service status' 129749@qq.com </service.txt

 

posted @ 2015-08-22 16:45  夨忆′  阅读(196)  评论(0编辑  收藏  举报