[root@server~]# service httpd stop
Stopping httpd:                                            [  OK  ]
[root@server ~]# ./checkapache.sh
httpd is NOT running. starting
Starting httpd:                                            [  OK  ]
[root@server ~]# ./checkapache.sh
httpd is running
[root@server~]# cat checkapache.sh
#!/bin/bash
 
if [ -z "$(pgrep httpd)" ]
  then
     echo "httpd is NOT running. starting"
     /sbin/service httpd start
  else
     echo "httpd is running"
fi
[root@server ~]#