检查服务运行状态

检查某一服务是否正常运行,执行脚本的时候第一个参数为服务名

#!/bin/bash
result=$(pidof $1 | wc -l)
echo ${result}
if [ ${result} -eq 0 ]
then
  echo "service does not exist !"
else
  echo "Service is running normally !"
fi

 

posted @ 2022-11-15 10:40  羊脂玉净瓶  阅读(28)  评论(0)    收藏  举报