zoukankan      html  css  js  c++  java
  • tomcat的初始化脚本(启动、退出、查看状态)

    #!/bin/bash
    #
    # Startup script for the tomcat
    #
    # chkconfig: 345 80 15
    # description: Tomcat is a Servlet+JSP Engine.


    # Source function library.
    . /etc/rc.d/init.d/functions


    RETVAL=0


    checkjava(){
            if [ -z "$JAVA_HOME" ]; then
                    export JAVA_HOME=/usr/java/jdk1.5.0_15
            fi
    }


    start(){
            checkjava
            checkrun
            if [ $RETVAL -eq 0 ]; then
                    echo "Starting tomcat"
                    /usr/tomcat/bin/startup.sh
                    touch /var/lock/subsys/tomcat
            else
                    echo "tomcat allready running"
            fi
    }


    stop(){
            checkjava
            checkrun
            if [ $RETVAL -eq 1 ]; then
                    echo "Shutting down tomcat"
                    /usr/tomcat/bin/shutdown.sh
                    #while [ $RETVAL -eq 1 ]; do
                            sleep 5
                            #checkrun
                    #done
    rm -f /var/lock/subsys/tomcat
            else
                    echo "tomcat not running"
            fi
    }


    checkrun(){
            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
                    RETVAL=1
                    return $RETVAL
            else
                    RETVAL=0
                    return $RETVAL
            fi
    }


    status(){
            checkrun
            if [ $RETVAL -eq 1 ]; 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
            echo "---------------------------------------------"
    }


    case "$1" in
    start)
            start
            ;;
    stop)
            stop
            ;;
    restart)
            stop
            start
            ;;
    status)
            status
            /usr/tomcat/bin/catalina.sh version
            ;;
    *)
            echo "Usage: $0 {start|stop|restart|status}"
            esac


    exit 0

  • 相关阅读:
    ASP.Net MVC的一个开源框架
    MS CRM 2011 RC中的新特性(8)
    在.NET4中用 jQuery 调用 WCF
    Web打印的在线设计
    MVC3.0RTM版本
    手机刷卡二维码
    Jla框架
    微软Windows Azure Platform技术解析
    缓存应用Memcached分布式缓存简介
    领域驱动设计(DDD)的理论知识
  • 原文地址:https://www.cnblogs.com/mazhiyong/p/2541657.html
Copyright © 2011-2022 走看看