码迷,mamicode.com
首页 > 编程语言 > 详细

Jar后台运行脚本 window-bat/unix-sh for springboot

时间:2018-06-06 22:16:41      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:for   配置   stop   自带   应用   输出类型   nat   art   file   

springboot项目,直接打包成jar

自带tomcat,可以通过java命令直接运行,无需web应用服务.

以maven为例,在pom.xml中配置打包输出类型:

<packaging>jar</packaging>

配置build:

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

打包成jar后,可以通过批处理直接启动或者停止.

window-bat

start:

@echo off
:wmic process where "commandline like ‘%%-jar reportcheck%%‘" call terminate
set path=C:\Program Files\Java\jre1.8.0_91\bin
START "reportcheck" "%path%\javaw" -jar reportcheck-0.0.1-SNAPSHOT.jar
pause

stop:

@echo off
wmic process where "commandline like ‘%%-jar reportcheck%%‘" call terminate
pause

unix-sh

start:

#!/bin/bash
if ps aux | grep -v ‘grep‘ | grep ‘java‘ | grep ‘reportcheck.jar‘
then
pid=$(ps aux | grep -v ‘grep‘ |grep ‘java‘|grep ‘reportcheck.jar‘| awk ‘{print $2}‘);
echo pid;
kill -9 ${pid};
echo old reportcheck exit...;
fi
nohup java -jar reportcheck.jar &> out &
echo reportcheck running...

stop:

#!/bin/bash
if ps aux | grep -v ‘grep‘ | grep ‘java‘ | grep ‘reportcheck.jar‘
then
pid=$(ps aux | grep -v ‘grep‘ |grep ‘java‘|grep ‘reportcheck.jar‘| awk ‘{print $2}‘);
echo pid
kill -9 ${pid};
fi

Jar后台运行脚本 window-bat/unix-sh for springboot

标签:for   配置   stop   自带   应用   输出类型   nat   art   file   

原文地址:https://www.cnblogs.com/ylpb/p/9146184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!