个人之自动启动jar

原创
2019/04/22 16:11
阅读数 242

前言

每次启动jar都挺麻烦了,需要删除已经启动的进程然后执行java命令,然后打开日志。显得无聊写一个脚本

大纲

在需要启动jar的当前目录执行就行了。如果要在命令行执行很简单。把文件放到usr/bin下面就行了。

#!/bin/bash

jar=`ls | grep *.jar`
echo “jar is $jar”
pid=`ps -elf | grep $jar  | grep java | awk  '{print $4}'`
echo "pid is $pid"
if [ -n "$pid" ];then
	kill $pid
fi

#--spring.profiles.active=test

nohup java -jar $jar  -Xms512m -Xmx1024m -XX:PermSize=128m &

file="logs/"`ls -t logs/ | grep logback | head -1`
echo $file
tail -f -n 200  $file

touch /usr/local/bin/start
chmod 777 /usr/local/bin/start
展开阅读全文
加载中

作者的其它热门文章

打赏
0
1 收藏
分享
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部