方法一:
linux 下tomcat开机自启动修改Tomcat/bin/startup.sh 为:export JAVA_HOME=/usr/java/j2sdk1.4.2_08export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.export PATH=$PATH:$JAVA_HOME/binexport CATALINA_HOME=/usr/local/tomcat/usr/local/tomcat/bin/catalina.sh start在/etc/rc.d/rc.local中加入:
/usr/local/tomcat/bin/startup.sh方法二:
1、把下面的代码保存为tomcat文件,并让它成为可执行文件 chmod 755 tomcat.
#!/bin/bash## kenny # /etc/rc.d/init.d/tomcat# init script for tomcat precesses## processname: tomcat# description: tomcat is a j2se server# chkconfig: 2345 86 16# description: Start up the Tomcat servlet engine.if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functionselif [ -f /etc/rc.d/init.d/functions ]; then. /etc/rc.d/init.d/functionselseecho -e "/atomcat: unable to locate functions lib. Cannot continue."exit -1fiRETVAL=$?
CATALINA_HOME="/usr/local/tomcat"case "$1" in
start)if [ -f $CATALINA_HOME/bin/startup.sh ];thenecho $"Starting Tomcat"$CATALINA_HOME/bin/startup.shfi;;stop)if [ -f $CATALINA_HOME/bin/shutdown.sh ];thenecho $"Stopping Tomcat"$CATALINA_HOME/bin/shutdown.shfi;;*)echo $"Usage: $0 {start|stop}"exit 1;;esacexit $RETVAL
2、将tomcat文件拷贝到/etc/init.d/下,并运行:chkconfig --add tomcat
3、在tomcat/bin/catalina.sh文件中加入以下语句:
export JAVA_HOME=/YOURPATH/tomcat/jdkexport CATALINA_HOME=/YOURPATH/tomcatexport CATALINA_BASE=/YOURPATH/tomcatexport CATALINA_TMPDIR=/YOURPATH/tomcat/temp启动tomcat: service tomcat start
停止tomcat: service tomcat stop