📜  如果停止,则在 bash 中启动服务 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:23.439000             🧑  作者: Mango

代码示例1
#!/bin/bash
SERVICE="nginx"
if pgrep -x "$SERVICE" >/dev/null
then
    echo "$SERVICE is running"
else
    echo "$SERVICE stopped"
    # uncomment to start nginx if stopped
    # systemctl start nginx
    # mail  
fi