#!/bin/bash
systemctl status httpd
if [ $? = 0 ]
then
echo "httpd is running"
else
echo "httpd do not running"
read -p "yes or no to restart httpd ?" DO
echo $DO
if [ $DO == yes ]
then
systemctl restart httpd
if [ $? = 0 ]
then
echo "restart success"
else
echo "restart failed"
fi
elif [ $DO == no ]
then
echo "script is stop"
else
echo "enter is error"
fi
fi
httpd do not running
yes or no to restart httpd ?yes
yes
restart success
[root@192 ~]# syste