zoukankan      html  css  js  c++  java
  • Linux下设置Tomcat开机启动

    1.进入/etc/rc.d/init.d,新建文件tomcat,并让它成为可执行文件 chmod 755 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.
    
    if [ -f /etc/init.d/functions ]; then
        . /etc/init.d/functions
    elif [ -f /etc/rc.d/init.d/functions ]; then
        . /etc/rc.d/init.d/functions
    else
        echo -e "/atomcat: unable to locate functions lib. Cannot continue."
    exit -l
    fi
    
    RETVAL=$?
    CATALINA_HOME="/usr/local/tomcat/apache-tomcat-8.0.44"
    
    case "$1" in
        start)
            if [ -f $CATALINA_HOME/bin/startup.sh ]; then
                echo $"Starting Tomcat"
                $CATALINA_HOME/bin/startup.sh
            fi
    
        ;;
        stop)
            if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then
                echo $"Stopping Tomcat"
                $CATALINA_HOME/bin/shutdown.sh
            fi
        ;;
        *)
            echo $"Usage: $0 {start|stop}"
            exit 1
        ;;
    esac
    
    exit $RETVAL


    相关命令的意思如下:
    -f filename  如果 filename为常规文件
    $0 是脚本本身的名字
    $? 是显示最后命令的退出状态,0表示没有错误,其他表示有错误


    2.执行chkconfig --add tomcat,将tomcat添加到指定的系统服务

    [root@ecs-3c46 ~]# chkconfig --add tomcat
    


    3.通过以下命令开启或关闭服务
    service tomcat start开启服务
    service tomcat stop关闭服务

  • 相关阅读:
    ReentrantLock与synchronized的差别
    读TIJ -1 对象入门
    wikioi 2573 大顶堆与小顶堆并用
    开源 免费 java CMS
    UVA10972
    springboot5
    spring-boot4
    spring-boot3
    spring-boot2
    spring-boot1
  • 原文地址:https://www.cnblogs.com/chenjianxiang/p/7255379.html
Copyright © 2011-2022 走看看