ok,这些都是刚开始,前面这些章节都是基础内容啦,高潮还在后面,慢慢更新!

   一般直接使用二进制版本的包,都需要直接找到相关路径使用相关脚本启动关闭脚本:  

[root@zonghe ~]# /usr/local/tomcat6/bin/startup.shUsing CATALINA_BASE:   /usr/local/tomcat6Using CATALINA_HOME:   /usr/local/tomcat6Using CATALINA_TMPDIR: /usr/local/tomcat6/tempUsing JRE_HOME:        /usr/local/jdk1.6.0_43/jreUsing CLASSPATH:       /usr/local/tomcat6/bin/bootstrap.jar[root@zonghe ~]# /usr/local/tomcat6/bin/shutdown.shUsing CATALINA_BASE:   /usr/local/tomcat6Using CATALINA_HOME:   /usr/local/tomcat6Using CATALINA_TMPDIR: /usr/local/tomcat6/tempUsing JRE_HOME:        /usr/local/jdk1.6.0_43/jreUsing CLASSPATH:       /usr/local/tomcat6/bin/bootstrap.jar

    或者  catalina.sh start  catalina.sh stop等参数,详见下面的命令参数详解

[root@zonghe ~]# /usr/local/tomcat6/bin/catalina.sh -hUsing CATALINA_BASE:   /usr/local/tomcat6Using CATALINA_HOME:   /usr/local/tomcat6Using CATALINA_TMPDIR: /usr/local/tomcat6/tempUsing JRE_HOME:        /usr/local/jdk1.6.0_43/jreUsing CLASSPATH:       /usr/local/tomcat6/bin/bootstrap.jarUsage: catalina.sh ( commands ... )commands:  debug             Start Catalina in a debugger  debug -security   Debug Catalina with a security manager  jpda start        Start Catalina under JPDA debugger  run               Start Catalina in the current window  run -security     Start in the current window with security manager  start             Start Catalina in a separate window  start -security   Start in a separate window with security manager  stop              Stop Catalina, waiting up to 5 seconds for the process to end  stop n            Stop Catalina, waiting up to n seconds for the process to end  stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running  stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running  version           What version of tomcat are you running?Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined

      如果使用rpm安装的话,在/etc/init.d/ 目录下会有tomcat相关的启动脚本,由于我们使用是二进制版本的tomcat包,所以就需要我们自己写一个相关的启动脚本的安装包,最简单的启动脚本如下:

[root@zonghe ~]# cat /etc/init.d/tomcat#!/bin/shJAVA_HOME=/usr/local/jdk1.6.0_43CATALINA_HOME=/usr/local/tomcat6export JAVA_HOME CATALINA_HOMEexec $CATALINA_HOME/bin/catalina.sh $*

  这个脚本很简单,其实就是调用catalina.sh这个脚本,$*就是把参数传给catalina.sh脚本,因为是调用catalina.sh 所以这个脚本能接的参数同catalina.sh。

   这里我们也可以写一个:

#!/bin/bash# chkconfig: 2345 10 90# description: Start and Stop the Tomcat daemon.                               TOMCAT_HOME=/usr/local/tomcatTOMCAT_START=$TOMCAT_HOME/bin/startup.shTOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh                               # necessary environment variables exportCATALINA_HOME=$TOMCAT_HOMEexport JAVA_HOME=/usr/local/jdk1.6.0_43                               # source function library.. /etc/rc.d/init.d/functions                               # source networking configuration.. /etc/sysconfig/network                               # check that networking is up.[ "${NETWORKING}" = "no" ] && exit 0                               # check for tomcat scriptif [ ! -f $TOMCAT_HOME/bin/catalina.sh ]then echo "Tomcat not valilable..."exitfi                               start(){    echo -n "Starting Tomcat: "    daemon $TOMCAT_START    echo    touch /var/lock/subsys/tomcat}                               stop(){    echo -n $"Shutting down Tomcat: "    daemon $TOMCAT_STOP    rm -f /var/lock/subsys/tomcat.pid echo                               }                               restart(){    stop    start}                               status(){    ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt    read line < /tmp/tomcat_process_count.txt    if [ $line -gt 0 ]; then        echo -n "tomcat ( pid "        ps ax --width=1000 | grep "org.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'        echo -n ") is running..."        echo    else        echo "Tomcat is stopped"    fi}                               case "$1" in    start)        start ;;    stop)        stop ;;    restart)        stop        sleep 3        start ;;    status)        status ;;    *)    echo "Usage: tomcatd {start|stop|restart|status}"    exit 1esacexit 0

   类似的脚本很多,这个脚本也是我参考网友的,其实我自己还是喜欢那个简单的脚本 =.=