tomcat6 设置成系统服务

脚本是针对tomcat6的,环境是CentOS,tomcat安装在/usr/local/tomcat6下面。下面是两个文件,一个是autorun.sh,autorun.sh用于将tomcat的

启动脚本复制到/etc/rc.d/init.d/下,另一个是tomcat,这就是tomcat的系统服务脚本。只需运行./autorun.sh就可以自动注册tomcat服务。

#!/bin/bash

#autorun.sh 用于注册tomcat服务


chmod 755 ./tomcat
cp ./tomcat /etc/rc.d/init.d/
chkconfig --add tomcat
chkconfig tomcat on
chkconfig --list tomcat

#!/bin/sh

#
# tomcat: Start/Stop/Restart tomcat
#
# chkconfig: 2345 80 20
# description: Tomcat is a Java Servlet Container
#
#
# match these values to your environment:

export CATALINA_BASE=/usr/local/tomcat6
export CATALINA_HOME=/usr/local/tomcat6
export CATALINA_TMPDIR=/usr/local/tomcat6/temp
export JRE_HOME=/usr/local/jdk1.6.0_31
export CLASSPATH=/usr/local/tomcat6/bin/bootstrap.jar

# Source function library.
. /etc/rc.d/init.d/functions

TOMCAT=/usr/local/tomcat6

start() {
echo -n $"Starting Tomcat: "
$TOMCAT/bin/startup.sh 
}

stop() {
echo -n $"Stopping Tomcat: "
$TOMCAT/bin/shutdown.sh 
}

# See how we were called.

case "$1" in
start)
	start
	;;
stop)
	stop
	;;

restart)
	stop
	start
	;;
*)
	echo $"Usage: $0 {start|stop|restart}"
	;;

esac

exit $RETVAL


你可能感兴趣的:(tomcat6)