感谢支持
我们一直在努力

Linux中让Tomcat5自动启动服务脚本的实现

RH linux系统中,如果简单的将$CATALINA_HOME/bin/startup.sh放在/etc/rc.local中,并不能使之自动启动。这里有些工作要做。假设已经安装好了jsvc(如何安装jsvc,请查看tomcat随机文档),在此,只写出tomcat的启动脚本如下:
 




#!/bin/sh
#
# Startup Script for Tomcat5
#
# chkconfig: 345 88 14
# description: Tomcat Daemon
# processname: jsvc
# pidfile: /var/run/jsvc.pid
# config:
#
# Source function library.
. /etc/rc.d/init.d/functions
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/local/jdk
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=$CATALINA_HOME/bin
TOMCAT_USER=tomcat5
# for multi instances adapt those lines.
TMP_DIR=/usr/local/tomcat/temp
PID_FILE=/usr/local/tomcat/logs/jsvc.pid
CATALINA_BASE=/usr/local/tomcat
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
case “$1” in
  start)
    #
    # Start Tomcat
    #
    $DAEMON_HOME/jsvc \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $CATALINA_HOME/logs/catalina.out \
    -errfile ‘&1’ \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;
  stop)
    #
    # Stop Tomcat
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;
  *)
    echo “Usage tomcat.sh start/stop”
    exit 1;;
esac

                   
  将此script放到/etc/init.d/目录中,加上可执行权限,就可以用chkconfig来配置了!

赞(0) 打赏
转载请注明出处:服务器评测 » Linux中让Tomcat5自动启动服务脚本的实现
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏