参考tomcat documentation,实现tomcat随linux启动而启动。详细内容如下:
http://tomcat.apache.org/tomcat-5.5-doc/setup.html
-----------------------------------------------------------
Unix daemonTomcat can be run as a daemon using the jsvc tool from the commons-daemon project. Source tarballs for jsvc are included with the Tomcat binaries, and need to be compiled. Building jsvc requires a C ANSI compiler (such as GCC), GNU Autoconf, and a JDK.Before running the script, the JAVA_HOME environment variable should be set to the base path of the JDK. Alternately, when calling the ./configure script, the path of the JDK may be specified using the --with-java parameter, such as ./configure --with-java=/usr/java.Using the following commands should result in a compiled jsvc binary, located in the $CATALINA_HOME/bin folder. This assumes that GNU TAR is used, and that CATALINA_HOME is an environment variable pointing to the base path of the Tomcat installation.注:楼主这样做最大弊端是拖缓系统启动,没有什么意义。

解决方案 »

  1.   

    把下面一段脚本存为 tomcat5,放在 /etc/init.d/#!/bin/sh# tomcat  start/stop script.# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
    # systems) and linked to /etc/rc3.d/S99tomcat and /etc/rc0.d/K01tomcat.
    # When this is done the mysql server will be started when the machine is
    # started and shut down when the systems goes down.# Comments to support chkconfig on RedHat Linux
    # chkconfig: 2345 90 90
    # description: A servlet/jsp container.# Comments to support LSB init script conventions
    ### BEGIN INIT INFO
    # Provides: honbo
    # Required-Start: $local_fs $network $remote_fs
    # Required-Stop: $local_fs $network $remote_fs
    # Default-Start:  3 5
    # Default-Stop: 3 5
    # Short-Description: start and stop tomcat
    # Description: A servlet/jsp container.
    ### END INIT INFO
     basedir=/data/tomcat5# Set some defaultspid_file=
    if test -z "$basedir"
    then
      basedir=/data/admin/tomcat
      bindir=/data/admin/tomcat/bin
    else
      bindir="$basedir/bin"
    fiPATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
    #add by honbo
    JAVA_HOME=/usr/java/j2sdk1.4.2_08
    CLASSPATH=$JAVA_HOME/lib/tools.jar:.
    PATH=$PATH:$JAVA_HOME/bin
    export JAVA_HOME CLASSPATH#end add by honbo
    export PATH
    mode=$1    # start or stop# Safeguard (relative paths, core dumps..)
    cd $basedircase "$mode" in
      'start')
        # Start daemon    #if test -x $bindir/startup.sh
        #then
          $bindir/startup.sh
        #else
         # echo "Can't execute $bindir/startup.sh from dir $basedir"
        #fi
        ;;  'stop')    
          $bindir/shutdown.sh
        
        #  echo "No tomcat stop sh file found. Looked for $bindir/shutdown.sh."
        
        ;;  'restart')
        # Stop the service and regardless of whether it was
        # running or not, start it again.
        $0 stop
        $0 start
                    ;;  *)
        # usage
        echo "Usage: $0 start|stop|restart"
        exit 1
        ;;
    esac