tomcat启动脚本

#!/bin/sh

# tomcat: Start/Stop/Restart tomcat

#

# chkconfig: 2345 85 15

# description: Apache tomcat6


# Small shell script to show how to start/stop Tomcat using jsvc


JAVA_HOME=/usr/java/jdk1.6.0


CATALINA_HOME=/usr/local/tomcat

DAEMON_HOME=$CATALINA_HOME/bin

# I did not use the user.

TOMCAT_USER=tomcat


# for multi instances adapt those lines.

TMP_DIR=$CATALINA_HOME/tmp

PID_FILE=$DAEMON_HOME/jsvc.pid

CATALINA_BASE=$CATALINA_HOME

. /etc/rc.d/init.d/functions

CATALINA_OPTS=

CLASSPATH=\

$JAVA_HOME/lib/tools.jar:\

$CATALINA_HOME/bin/commons-daemon.jar:\

$CATALINA_HOME/bin/bootstrap.jar


start() {

echo -n $"Starting Tomcat6: "

# If you want to specify a user to run Tomcat.

#increase the 'user $ TOMCAT_USER \' to the parameter list.

$DAEMON_HOME/jsvc \

-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

echo "*****************************[ok]"

}


stop() {

echo -n $"Stopping Tomcat6: "

#

$DAEMON_HOME/jsvc \

-stop \

-pidfile $PID_FILE \

org.apache.catalina.startup.Bootstrap

echo "*****************************[ok]"

}


status() {

ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap" | 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 "tomcat6 ( pid "

ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap" | awk '{printf $1 " "}'

echo ") is running "

else

echo "Tomcat6 is stopped"

fi

}


case "$1" in

start)

# Start Tomcat

start

exit $?

;;


stop)

# Stop Tomcat

stop

exit $?

;;

restart)

# Restart Tomcat

stop

sleep 3

start

exit $?

;;

status)

status

exit $?

;;

*)

echo "Usage: tomcat6 {start|stop|restart|status}"

exit 1;;

esac


#####


####


你可能感兴趣的:(tomcat,启动脚本)