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

#!/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
原文地址:https://www.cnblogs.com/sysk/p/4750559.html