Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

start a service in bash if stopped

#!/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
Source by www.cyberciti.biz #
 
PREVIOUS NEXT
Tagged: #start #service #bash #stopped
ADD COMMENT
Topic
Name
7+8 =