栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Windows/Linux替换jar内配置文件

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Windows/Linux替换jar内配置文件

windows

把待替换文件放到与jar包同级目录下,执行CMD指令

#jar uf ***.jar 替换的文件名
jar uf pc-application-1.0-SNAPSHOT.jar BOOT-INF/classes/application-local.properties

Linux  替换文件并启动shell脚本

jar  uvf ***.jar  要替换的文件
#!/bin/bash
#name:jar包启动脚本;
#date:2021-9-16;
#author:Hou-XiaoYang

#此处修改脚本名称:
APP_NAME=pc-application-1.0-SNAPSHOT.jar
UF_NAME=BOOT-INF/classes/application-local.properties
#脚本菜单项
usage() {
 echo "Usage: sh tf.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
#此处注意修改jar和log文件文件位置:
jar  uvf $APP_NAME  $UF_NAME
nohup java -jar $APP_NAME > bootdolog.log   2>&1 &
#此处打印log日志:
tail -f bootdolog.log
 fi
}
#停止脚本
stop(){
 is_exist
 if [ $? -eq "0" ]; then
 kill -9 $pid
 else
 echo "${APP_NAME} is not running"
 fi
}
#显示当前jar运行状态
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
 start
}

case "$1" in
 "start")
 start
 ;;
 "stop")
 stop
 ;;
 "status")
 status
 ;;
 "restart")
 restart
 ;;
 *)
 usage
 ;;
esac

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/321571.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号