用is-active命令检测服务是否运行,没运行就直接启动运行
检测nginx是否运行
#!/bin/bash
status=$(systemctl is-active nginx)
if [ "$status" == "active" ]; then
echo "nginx is running";
else
echo "nginx is not running";
systemctl start nginx;
fi
没有运行运行命令开始运行
版权申明
本文系作者 @天边的云 原创发布在Loshub站点。未经许可,禁止转载。
暂无评论数据