美文网首页
Linux系统下用命令快捷启动tomcat的脚本

Linux系统下用命令快捷启动tomcat的脚本

作者: Joker阳光 | 来源:发表于2017-12-06 13:03 被阅读0次

    1.脚本路径 /etc/init.d/tomcat

    首先执行: vi /etc/init.d/tomcat
    将下面内容根据你自己的情况(主要是修改 /usr/local/tomcat7 )
    修改后copy到编辑框中, esc 退出编辑,:wq 保存退出
    
    # !/bin/bash    
    # Description: start or stop the tomcat    
    # Usage:        tomcat [start|stop|restart]    
    #    
    export PATH=$PATH:$HOME/bin
    export BASH_ENV=$HOME/.bashrc
    export USERNAME="root"
    
    tomcatHome=/usr/local/tomcat7
    
    case "$1" in
    start)
    #startup the tomcat    
    cd ${tomcatHome}/bin
    ./startup.sh
    ;;
    stop)
    # stop tomcat    
    cd ${tomcatHome}/bin
    ./shutdown.sh
    echo "Tomcat Stoped"
    ;;
    restart)
    $0 stop
    $0 start
    ;;
    serconf)
    cd ${tomcatHome}/conf
    vim ./server.xml
    ;;
    catconf)
    vim ${tomcatHome}/bin/catalina.sh
    ;;
    log)
    cd ${tomcatHome}/logs
    cat ./catalina.out
    ;;
    clearlog)
    cd ${tomcatHome}/logs
    rm -rf ./*
    ;;
    state)
    ps -aux|grep tomcat
    ;;
    *)
    echo "tomcat: usage: tomcat [start|stop|restart|serconf|catconf|log|tail|clearlog|state]"
    exit 1
    esac
    exit 0
    

    2.更改tomcat脚本为可执行文件

    chmod +x /etc/init.d/tomcat  
    

    3.为了在任意路径都可执行此脚本,需要添加到/usr/bin目录中

    cd /usr/bin
    ln -s /etc/init.d/tomcat
    

    相关文章

      网友评论

          本文标题:Linux系统下用命令快捷启动tomcat的脚本

          本文链接:https://www.haomeiwen.com/subject/tobkixtx.html