windows如何使用bat指令碼後臺啟動/停止和重啟jar包服務
阿新 • • 發佈:2020-11-29
前提: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
到此這篇關於windows如何使用bat指令碼後臺啟動/停止和重啟jar包服務的文章就介紹到這了,更多相關windows用bat指令碼啟動/停止重啟jar包內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!