如下是腳本程序
#chkconfig: 35 85 15
#description: Apache is a World Wide Web Server
start(){
/usr/local/httpd/bin/apachectl start
echo "httpd server start"
touch /tmp/apached.txt
}
stop(){
/usr/local/httpd/bin/apachectl stop
echo "httpd server is stoped"
rm -rf /tmp/apached.txt
}
restart(){
if [ -e /tmp/apached ];then
# killall -9 /usr/local/httpd/bin/httpd
stop
killall -9 /usr/local/httpd/bin/httpd
start
else
echo "httpd server is stopd"
start
fi
}
status(){
if [ -e /tmp/apached.txt ];then
echo "httpd server is running"
else
echo "http server is stopd"
fi
}
#read -p "/etc/init.d/apached" type
case "$1" in
"start")
start ;;
"stop")
stop ;;
"status")
status ;;
"restart")
restart ;;
*)
echo "/etc/init.d/apached options: stop|start|status|restart"
esac