软件编程
位置:首页>> 软件编程>> java编程>> windows如何使用bat脚本后台启动/停止和重启jar包服务

windows如何使用bat脚本后台启动/停止和重启jar包服务

作者:阿来小同学  发布时间:2022-02-27 12:28:36 

标签:bat,脚本,jar包

前提:windows上安装jdk

1.启动jar脚本


@echo off
START "app" javaw -jar app-0.0.1-SNAPSHOT.jar

2.停止jar脚本(如:jar包端口9090)


@echo off
set port=9090
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
echo kill the process %%m who use the port
taskkill /pid %%m -t -f
goto q
)
:q

3.重启jar脚本(就是上面两个合起来)


@echo off
set port=9090
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
echo kill the process %%m who use the port
taskkill /pid %%m -t -f
goto start
)
:start

START "app" javaw -jar app-0.0.1-SNAPSHOT.jar

来源:https://blog.csdn.net/skybboy/article/details/106254309

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com