Linux下tomcat加入到服务中

 
#!/bin/sh
# chkconfig: 2345 10 90 
# description: tomcat service for ....
#将此文件保存到/etc/rc.d/init.d/下面
#此文件的文件名就是要注册的服务名,比如文件名保存成:tom-ctms
#使用的命令是:service tom-ctms start/stop/restart
#添加开机启动:chkconfig --add tom-ctms

. /etc/rc.d/init.d/functions

prog=centerumms
tomDir=/usr/apache-tomcat-6.0.33/
start()
{
        ${tomDir}bin/startup.sh
        action $"Starting $prog: " /bin/true
}

stop()
{
        kill -9 `ps -ef | grep ${tomDir} | grep java | awk '{print $2}'`
        action $"Stopping $prog: " /bin/true
}


case "$1" in
start)
        start
;;
stop)
        stop
;;
restart)
                stop
                sleep 3
                start
;;
*)
                echo "Usage: /etc/init.d/${prog}d {start|stop|restart}"
esac
 
 
 

猜你喜欢

转载自linhexiao.iteye.com/blog/2304832