tomcat自启动脚本

1、#cd /etc/rc.d/init.d
2、#vi tomcat
3、把下面的代码保存为tomcat文件,并让它成为可执行文件 chmod 755 tomcat.

#!/bin/sh
#
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2ee server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.

if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "\atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi

RETVAL=$?
CATALINA_HOME="/usr/local/apache-tomcat-8.0.11"

case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac

exit $RETVAL

4、运行:chkconfig --add tomcat
5、chmod 755 -R /etc/rc.d/init.d/tomcat

6、在tomcat/bin/catalina.sh文件中的前面加入以下语句:

export JAVA_HOME=/usr/java/jdk1.7.0_67
export CATALINA_HOME=/usr/local/apache-tomcat-8.0.11
export CATALINA_BASE=/usr/local/apache-tomcat-8.0.11
export CATALINA_TMPDIR=/usr/local/apache-tomcat-8.0.11/temp

测试tomcat能不能启动 启动tomcat: service tomcat start
测试tomcat能不能停止 停止tomcat: service tomcat stop

启动方式中该服务是启动 #chkconfig tomcat on  
#chkconfig --list tomcat

posted @ 2017-01-22 13:26  humor1314  阅读(309)  评论(0编辑  收藏  举报