#!/bin/bash //第一行的#号是注释,其他的#号开头的不是注释
# chkconfig: 2345 55 25 //运行级别,开机启动优先权,关闭优先权
# description: httpd is a protocol for web service. //关于服务的描述
# This service starts up the httpd server daemon.
#
# processname: httpd //进程名称
下面是脚本内容
service=httpd
servicedir=/usr/local/apache2/bin
start () {
$servicedir/apachectl start
touch /usr/local/apache2/bin/lock
echo "$service is running..."
}
stop () {
$servicedir/apachectl stop
rm -rf /usr/local/apache2/bin/lock
echo "$service is stopped"
}
status () {
if [ -f /usr/local/apache2/bin/lock ];then
echo "$service is running....."
else
echo "$service is stopped"
fi
}
restart () {
stop
start
}
case "$1" in
start)
start ;;
stop)
stop ;;
status)
status;;
restart)
restart;;
*)
echo "$0: usage start|stop|status|restart"
esac