检测服务

[root@mysql shell]# cat checkService.sh
#!/bin/bash

services=(nginx java mysqld mongod)
checkServices(){
ss -ntlp |grep $1 > /dev/null
[ $? -eq 0 ] && echo "$1"" is OK!" || echo "$1"" is stop"
#[ $? -eq 0 ] && return 0 || return 1
}
#checkServices $1
for service in ${services[@]}
do
checkServices $service
done

 

 

posted @ 2020-10-18 17:40  水中鱼2018  阅读(131)  评论(0编辑  收藏  举报