linux shell學習之自動檢測並重啟httpd服務
[root@localhost shell]# cat checkapache.sh
#!/bin/bash
#using your program to show your system's service
echo "Now,the web service of linux system will be detected..."
echo
#Detect www service
#web=`/usr/bin/pgrep httpd`
web=$(/usr/bin/pgrep httpd)
if [ "$web" != "" ]
then
echo "The web service is running now."
else
echo "The web service is NOT running,It Will running Now!"
/etc/rc.d/init.d/httpd start
fi
======================================
將上面的腳本加入計劃執行,就可以檢測並啟動httpd服務了,對網站運維管理特別有用。