zoukankan      html  css  js  c++  java
  • linux下的启停脚本

    linux下的根据项目名称,进行进程的启停脚本

    #!/bin/bash
    
    JAVA=/usr/bin/java
    APP_HOME=/opt/program/qa/wechat
    APP_NAME=programname.jar
    APP_PARAM="--spring.config.location=${APP_HOME}/application.properties --logging.path=${APP_HOME}"
    
    case $1 in
    start)
    PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
    if [ -z "$PID" ] ;then
            echo "start ${APP_NAME}"
            nohup ${JAVA} -Dfile.encoding=utf-8  -jar ${APP_HOME}/${APP_NAME} ${APP_PARAM}  > /dev/null 2>&1  &
    else
            echo "${APP_NAME} is running"
    fi
    ;;
    
    stop)
    PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
    if [ -z "$PID" ] ;then
            echo "${APP_NAME} is not running"
    else
            echo "stop ${APP_NAME}"
            kill -9 $PID
    fi
    ;;
    
    restart)
    PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
    if [ -z "$PID" ] ;then
            echo "start ${APP_NAME}"
            nohup ${JAVA} -Dfile.encoding=utf-8  -jar ${APP_HOME}/${APP_NAME} ${APP_PARAM}   > /dev/null 2>&1  &
    else
            echo "stop ${APP_NAME}"
            kill -9 $PID
            echo "start ${APP_NAME}"
            nohup ${JAVA} -Dfile.encoding=utf-8  -jar ${APP_HOME}/${APP_NAME} ${APP_PARAM}   > /dev/null 2>&1  &
    fi
    ;;
    
    logs)
    tail -f ${APP_HOME}/catalina.out
    ;;
    
    status)
    PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
    if [ -z "$PID" ] ;then
            echo "${APP_NAME} is not running"
    else
            echo "${APP_NAME} is running, pid $PID"
    fi
    ;;
    
    esac
    

      

  • 相关阅读:
    洛谷P3796
    cf1291c-Mind Control
    莫比乌斯函数
    C. Mixing Water(三分)
    E. Modular Stability(思维构造)
    【美团杯2020】平行四边形
    原根定义
    E. Are You Fired?(思维)
    102606C. Coronavirus Battle time limit per test4 seconds(三维拓扑序)
    E
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/10788808.html
Copyright © 2011-2022 走看看