• 使用tomcat脚本开启服务


    参考:https://www.cnblogs.com/fps2tao/p/8488596.html

    1、编写tomcat脚本

    在/etc/init.d/目录下创建tomcat服务脚本文件

    cd  /etc/init.d

    nano tomcat

    复制粘贴以下内容

    #!/bin/bash
    #
    # tomcat startup script for the Tomcat server
    #
    #
    # chkconfig: 345 80 20
    # description: start the tomcat deamon
    #
    # Source function library
    . /etc/rc.d/init.d/functions
    
    prog=tomcat8
    JAVA_HOME=/usr/java/jdk1.8.0_202-amd64  # 根据自己的路径改写JAVA_HOME
    export JAVA_HOME
    CATALANA_HOME=/usr/local/server/tomcat   # 根据自己的路径改写CATALANA_HOME
    export CATALINA_HOME
    
    case "$1" in
    start)
        echo "Starting Tomcat..."
        $CATALANA_HOME/bin/startup.sh
        ;;
    
    stop)
        echo "Stopping Tomcat..."
        $CATALANA_HOME/bin/shutdown.sh
        ;;
    
    restart)
        echo "Stopping Tomcat..."
        $CATALANA_HOME/bin/shutdown.sh
        sleep 2
        echo
        echo "Starting Tomcat..."
        $CATALANA_HOME/bin/startup.sh
        ;;
    
    *)
        echo "Usage: $prog {start|stop|restart}"
        ;;
    esac
    exit 0

    2、赋权限,测试tomcat脚本

    [root@localhost /]# cd /etc/init.d/
    [root@localhost init.d]# chmod 755 tomcat8    #赋予权限
    [root@localhost init.d]# service tomcat8 start  #启动服务
    Starting tomcat8 (via systemctl):                          [  确定  ]
    [root@localhost init.d]# service tomcat8 stop   #停止服务
    Stopping tomcat8 (via systemctl):                          [  确定  ]
    [root@localhost init.d]# service tomcat8 restart  #重启服务
    Restarting tomcat8 (via systemctl):                        [  确定  ]

    3、将服务脚本加入到服务启动队列

     可用systemctl  status  tomcat查看服务启动状态

    4、重启,测试配置结果

  • 相关阅读:
    Robberies
    Big Event in HDU
    UVA 562 Dividing coins
    Little Rooks
    Bone Collector
    Piggy-Bank
    0-1背包问题之——饭卡
    Monkey and Banana
    The Triangle
    Burning Midnight Oil
  • 原文地址:https://www.cnblogs.com/flypig666/p/11710245.html
Copyright © 2020-2023  润新知