tomcat_autostart(tomcat註冊爲服務腳本)

#!/bin/bash
#
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description:  Start up the Tomcat servlet engine.

JAVA_HOME=/home/dev/jdk1.7.0_79/

CATALINA_HOME=/home/culture-analysis/tomcat_culture-analysis

CLASSPATH=.:${CLASSPATH}:${JAVA_HOME}/lib

# 
start()
{
	cp -rf /home/culture-analysis/application.properties /home/culture-analysis/tomcat_culture-analysis/webapps/analysis/WEB-INF/classes
	cd  /home/culture-analysis/tomcat_culture-analysis
	rm -rf work
	mkdir work
	cd /home/culture-analysis
        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 | grep $CATALINA_HOME|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill
            echo " OK"
            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
相關文章
相關標籤/搜索