centos 配置tomcat开机启动的方法

  • 2016-10-3 11:52
  • PHP二次开发
  • 阅读(2162)
  • 评论(0)
  • 来源:互联网
  • 摘要: tomcat.sh内容如下:#!/bin/bash# chkconfig: 2345 40 20# description: Starts and Stops the Tomcat daemon.TOMCAT_HOME=/usr/local/tomcatTOMCAT_START=$TOMCAT_HOME/bin/startup.shTOMCAT_STOP=$TOMCAT_HOME/bin ...
    tomcat.sh内容如下:

    #!/bin/bash
    # chkconfig: 2345 40 20
    # description: Starts and Stops the Tomcat daemon.
    TOMCAT_HOME=/usr/local/tomcat
    TOMCAT_START=$TOMCAT_HOME/bin/startup.sh
    TOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh
    # necessary environment variables export
    CATALINA_HOME=$TOMCAT_HOME
    export JAVA_HOME=/usr/java/jdk1.8.0_73
    # source function library.
    . /etc/rc.d/init.d/functions
    # source networking configuration.
    #. /etc/rc.d/network
    # check that networking is up.
    [ "${NETWORKING}" = "no" ] && exit 0
    # check for tomcat script
    if [ ! -f $TOMCAT_HOME/bin/catalina.sh ]
    then echo "Tomcat not valilable..."
    exit
    fi
    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 1
    esac
    exit 0


    将tomcat.sh放到/etc/init.d目录
    执行:chkconfig toncate on



    PHP技术交流QQ群:422137578

    除非注明,文章均为 PHP二次开发 原创,转载请注明本文地址:http://www.php2.cc/article-2475-1.html

    相关阅读

    最新评论

    用户名:  *

    邮 箱:  *

    网 址: 注意加上“http://”哦!