zoukankan      html  css  js  c++  java
  • Linux 的 tomcat 自起服务

    1. 使用 roo t用户进入 etc/init.d

     cd etc/init.d
    

    2. 使用 vi 编辑 tomcat 服务

     vi tomcat
    

    3. 在 vi 编辑器中加入以下脚本命令

    #! /bin/sh
        #
        # tomcatd  This shell script takes care of starting and stopping tomcat
        #
        # chkconfig: 2345 59 63
         
        # Source funcation library.
        . /etc/init.d/functions
         
        # Source networking configuration.
        . /etc/sysconfig/network
        export JAVA_HOME=/usr/local/java/jdk1.7.0_80
        export tomcat_home=/usr/local/tomcat7
        export tomcatStart=$tomcat_home/bin/startup.sh
        export tomcatStop=$tomcat_home/bin/shutdown.sh
         
        start() {
            $tomcatStart
        }
         
        stop() {
            $tomcatStop
        }
         
        status() {
            num=`ps -ef | grep -w $tomcat_home | grep -v grep | wc -l`
            if [ $num -gt 0 ]
            then echo "tomcat is running"
            else echo "tomcat is stoped"
            fi
        }
         
        # See how we were called.
         
        case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            start
            ;;
        status)
            status $prog
            ;;
        *)
            echo $"Usage: $0 {start|stop|restart|status}"
            exit 2
        esac
        exit
    

    4. 添加脚本执行权限

     chmod 755 /etc/init.d/tomcat
    

    5. 使用 chkconfig 添加系统服务

     chkconfig --add tomcat
    

    6. 使用 chkconfig 查看是否添加成功

     chkconfig --list tomcat
    

    7. 现在可以用 service tomcat stop|start|status|restart 来管理 tomcat

     service tomcat status
    

    可以将 tomcat 进程关闭,重启 Linux 服务器,执行 service tomcat status,会发现 tomcat 正在运行。

  • 相关阅读:
    VKD224B触摸芯片调试笔记
    liunx 常用命令学习笔记
    2440 裸机学习 点亮LED
    单端正激变换器
    c# 文件与流
    c# 接口笔记
    Ubuntu18.04 server安装步骤
    how to force git to overwritten local files
    Linux基础
    解决Linux下Firefox无法启动的问题
  • 原文地址:https://www.cnblogs.com/breakfei/p/14085932.html
Copyright © 2011-2022 走看看