linux脚本启动jar包

  • run.sh

    shell 复制代码
    #!/bin/bash
    cd /home/java_projects/yh_oa_api/
    nohup java -jar yh_oa_api.jar --spring.profiles.active=dev --server.port=9023 > /dev/null 2>&1 &
    echo "yh_oa_api.jar run successfully!"
  • stop.sh

    shell 复制代码
    #!/bin/bash
    
    echo "search [yh_oa_api.jar] process ......"
    
    pid=`ps -ef | grep "yh_oa_api.jar" | grep -v grep | awk '{print $2}'`
    
    if [[ pid>0 ]]; then
        echo "Process [ yh_oa_api.jar  ] is runing , PID = $pid ;"
    
        echo "Now Will Kill Process PID = $pid ;"
    
        result=`kill -9 $pid`
    else
        echo "Process [ yh_oa_api.jar ] stop success! ;"
    fi
  • restart.sh

    shell 复制代码
    #!/bin/bash
    source /etc/profile
    
    # 要发布的jar包名称
    NEW_JAR='yh_oa_api.jar'
    
    
    # 停止正在运行的jar包
    pid=`ps -ef|grep $NEW_JAR| grep -v grep| awk '{print $2}'`
    echo "部署前的pid进程 :$pid"
    
    
    # 关闭已经启动的jar进程
    if [ -n "$pid" ]
      then
        kill -9 $pid
    else
        echo "进程没有启动"
    fi
    
    # cd到jar包目录
    cd  /home/java_projects/yh_oa_api
    
    # 启动
    nohup java -agentpath:/tmp/cdbg_java_agent.so -jar  $NEW_JAR --spring.profiles.active=dev --server.port=9023  >/dev/null 2>&1 &
    echo "脚本执行完毕"
    
    pid=`ps -ef|grep $NEW_JAR | grep -v grep | awk '{print $2}'`
    
    # 检验进程是否启动
    if [ -n "$pid" ]
      then
            echo "部署后的pid进程 :$pid"
            echo "启动成功"
    else
        echo "进程没有启动"
    fi
相关推荐
小筱在线3 小时前
在SpringCloud中实现服务间链路追踪
后端·spring·spring cloud
计算机学姐3 小时前
基于SpringBoot+Vue的高校门禁管理系统
java·vue.js·spring boot·后端·spring·intellij-idea·mybatis
大熊程序猿3 小时前
go 安装依赖超时
开发语言·后端·golang
计算机学姐4 小时前
基于SpringBoot+Vue的宠物医院管理系统
java·vue.js·spring boot·后端·mysql·intellij-idea·mybatis
JosieBook5 小时前
【.NET全栈】ASP.NET实战—基于ASP.NET的求职系统设计与实现
后端·asp.net·.net
customer085 小时前
【开源免费】基于SpringBoot+Vue.JS教师工作量管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
AskHarries5 小时前
Spring Boot集成LangChain来实现Rag应用
java·spring boot·后端
黄俊懿5 小时前
【深入理解SpringCloud微服务】了解微服务的熔断、限流、降级,手写实现一个微服务熔断限流器
java·分布式·后端·spring cloud·微服务·架构·手写源码
Xua30556 小时前
浅谈Spring Cloud:OpenFeign
后端·spring·spring cloud
蓝染-惣右介7 小时前
【若依RuoYi-Vue | 项目实战】帝可得后台管理系统(二)
java·前端·后端·vue·springboot