Tomcat启动、关闭、重启脚本

#!/bin/sh

#chkconfig: 345 90 10

#tomcat auto-start

#. /etc/init.d/functions

#. /etc/sysconfig/network

RETVAL=0

export JAVA_HOME=/usr/local/jdk

export JRE_HOME=/usr/local/jdk/jre

export CATALINA_HOME=/usr/local/tomcat

export CATALINA_BASE=/usr/local/tomcat

start()

{

if [ -f $CATALINA_HOME/bin/startup.sh ];

then

    echo $"Starting Tomcat"

    $CATALINA_HOME/bin/startup.sh

    RETVAL=$?

    echo "OK"

    return $RETVAL

fi

}

stop()

{

if [ -f $CATALINA_HOME/bin/shutdown.sh ];

then

            echo $"Stopping Tomcat" 

            $CATALINA_HOME/bin/shutdown.sh 

            RETVAL=$? 

            sleep 1

    ps -fwwu root | grep tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9 

            echo " OK" 

            # [ $RETVAL -eq 0 ] && rm -f /var/lock/... 

            return $RETVAL 

fi

}

case "$1" in

start)

start

;;

stop)

stop

;;

restart)

  echo $"Restaring Tomcat" 

        $0 stop 

        sleep 1 

        $0 start 

        ;;

*)

  echo $"Usage: $0 {start|stop|restart}" 

        exit 1 

        ;;

esac 

exit $RETVAL 

##mv tomcatd /etc/init.d/

###chmod +x /etc/init.d/tomcatd

##chkconfig --add tomcatd  or chkconfig tomcatd on

##ps auwwx|grep tomcat|grep -v grep|grep -v PID|awk '{print $2}'|xargs kill -9

你可能感兴趣的:(Tomcat启动、关闭、重启脚本)