Tips: write a shell into /etc/crontab check the service automatically

#!/bin/bash

PORT=:80 #The port, the : makes it easy to snag only ports and not other numbers in the output.

INITS=httpd #The name of the service in /etc/init.d/

COUNT=$(netstat -lpn grep $ wc -l)

if [ $COUNT -lt 1 ]

then

/etc/init.d/$INITS start

fi