zoukankan      html  css  js  c++  java
  • CentOS Shell 脚本备份和重启 JAR 服务

    1、JAR 备份 Shell 脚本 shaolinTemple-mobile_backup.sh:

    #!/bin/sh
    # author hapday 
    # date 2020-07-27
    
    echo "为备份后的 JAR 文件名添加日期和时间标识:"
    
    date +%Y-%m-%d-%H-%M-%S
    
    MOBILE_HOME=/usr/local/shaolinTemple/server/mobile/
    
    mv ${MOBILE_HOME}shaolinTemple-mobile.jar ${MOBILE_HOME}shaolinTemple-mobile.jar_$(date +%Y-%m-%d-%H-%M-%S)
    echo '重命名 shaolinTemple-mobile.jar 文件。'

    2、JAR 的重启 Shell 脚本 shaolinTemple-mobile_restart.sh:

    #!/bin/bash
    # author hapday 2020-07-27
    
    source /etc/profile
    
    export JAVA_HOME=/usr/local/jdk1.8.0_241/    # 此行不可去掉
    export MOBILE_SERVICE_HOME=/usr/local/shaolinTemple/server/mobile
    
    echo "进入到移动服务的根目录中:" ${MOBILE_SERVICE_HOME}
    cd ${MOBILE_SERVICE_HOME}
    
    MOBILE_SERVICE_PID=$(ps aux | grep shaolinTemple-mobile.jar | grep -v grep | awk '{print $2}')
    echo "移动服务的 PID = " ${MOBILE_SERVICE_PID}
    
    for mobile_pid in ${MOBILE_SERVICE_PID}
    do 
        kill -9 ${mobile_pid}
        echo "成功停止移动服务。"
    done
    
    # chmod 775 *.sh
    
    echo "启动移动服务..."
    nohup java -jar shaolinTemple-mobile.jar > /log/shaolinTemple/mobile/mobile.log &

    3、WAR 包的 Shell 备份、重启脚本与此类似,将 jar 替换为 war 即可。

  • 相关阅读:
    D
    hdu2376 Average distance (树形dp)
    hdu2376 Average distance (树形dp)
    选拔赛——旅游
    选拔赛——旅游
    cf 990c(思维+括号匹配)
    cf 990c(思维+括号匹配)
    Garland CodeForces
    Garland CodeForces
    Sherlock and his girlfriend CodeForces
  • 原文地址:https://www.cnblogs.com/hapday/p/13387186.html
Copyright © 2011-2022 走看看