检测服务
[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