shell/检测服务是否关闭.txt

16 lines
334 B
Plaintext
Raw Permalink Normal View History

2024-05-30 20:47:26 +08:00
#!/usr/bin/bash
#检查服务是否关闭
#by fuxiaoshun 3/29
read -p "请输入服务名:" name
ss -tnlp | grep $name &>/dev/null
if [ $? -eq 0 ];then
echo "服务已经启动"
else
yum -y install $name &>/dev/null
systemctl restart $name
echo "$name 重新启动成功"
fi