zoukankan      html  css  js  c++  java
  • JAR包启动

    #!/bin/bash
    tomcat_name=jenkins
    port=8080
    tomcat_home=/application/tomcats
    SHUTDOWN=$tomcat_home/$tomcat_name/bin/shutdown.sh
    STARTTOMCAT=$tomcat_home/$tomcat_name/bin/startup.sh
    
    start() {
    	if      ss -an | grep $port | grep LISTEN >/dev/null 
    	then
    		echo "$tomcat_name已经启动,请勿重复启动!"
    	else
    		$STARTTOMCAT
    	fi
    }
    
    stop() {
            if ss -an | grep $port | grep LISTEN >/dev/null
            then
                    $SHUTDOWN
            else
                    echo "$tomcat_name 未启动"
            fi
    }
    
    case $1 in
    start)
    echo "启动$tomcat_name"
    start
    ;;
    stop)
    echo "关闭$tomcat_name"
    stop
    ;;
    restart)
    echo "关闭$tomcat_name"
    stop
    
    sleep 3
    echo "启动$tomcat_name"
    start
    ;;
    *)
    echo $"Usage: $0 {start|stop|restart}" 
    esac
    
    

    查出5个最近修改的文件保留 其他的删除

    
    [root@ceshi jenkins]# ls -lrt |tail -5|awk '{print $NF}'
    bin
    conf
    tomcat.sh
    webapps
    temp
    [root@ceshi jenkins]# ll |grep -v "`ls -lrt |tail -5|awk '{print $NF}'`"
    
    
    #!/bin/sh
    echo "  =====关闭Java应用======"
    PROCESS=`ps -ef |grep java |grep -v grep|grep xxx.jar|awk '{print $2}'`
    for i in $PROCESS
    do
      echo "Kill the $1 process [ $i ]"
      kill -9 $i
    done
    echo "  =====启动Java应用======"
    nohup java -jar xxx.jar  > out.log 2>&1 & 
    echo $! > savePid.txt
    cat savePid.txt
    rm  savePid.txt
    
    #!/bin/bash
    APP_NAME=/application/jar/blade-auth.jar
    LOG=/application/jar/log/blade-auth.out
    #使用说明,用来提示输入参数
    usage() {
    echo "Usage: sh robotcenter.sh [start|stop|restart|status]"
    exit 1
    }
    
    #检查程序是否在运行
    is_exist(){
    pid=$(ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}')
    #如果不存在返回1,存在返回0
    if [ -z "${pid}" ]; then
    return 1
    else
    return 0
    fi
    }
    
    #启动方法
    start(){
    is_exist
    if [ $? -eq 0 ]; then
    echo "${APP_NAME} is already running. pid=${pid}"
    else
    echo "${APP_NAME} 正在启动!"
    nohup java -jar -Xms512M -Xmx1024M -XX:PermSize=512M -XX:MaxPermSize=1024M $APP_NAME >$LOG 2>&1 &
    fi
    }
    
    #停止方法
    stop(){
    is_exist
    if [ $? -eq "0" ]; then
    echo "${APP_NAME} 正在停止!"
    kill -9 $pid
    else
    echo "${APP_NAME} is not running"
    fi
    }
    
    #输出运行状态
    status(){
    is_exist
    if [ $? -eq "0" ]; then
    echo "${APP_NAME} is running. Pid is ${pid}"
    else
    echo "${APP_NAME} is NOT running."
    fi
    }
    
    #重启
    restart(){
    stop
    sleep 2
    start
    }
    
    #根据输入参数,选择执行对应方法,不输入则执行使用说明
    case "$1" in
    "start")
    start
    ;;
    "stop")
    stop
    ;;
    "status")
    status
    ;;
    "restart")
    restart
    ;;
    *)
    usage
    ;;
    esac
    
    
    
    mvn -DskipTests clean package
    

    http://idea.medeming.com/jets/

  • 相关阅读:
    .NET Core开发日志——从搭建开发环境开始
    通过Docker构建TensorFlow Serving
    通过Jenkins在IIS上布署站点
    RabbitMQ in Depth札记——AMQ协议
    Web API对application/json内容类型的CORS支持
    ng-book札记——路由
    ng-book札记——HTTP
    ng-book札记——依赖注入
    UVA
    POJ
  • 原文地址:https://www.cnblogs.com/zdqc/p/12784721.html
Copyright © 2011-2022 走看看