Linux shell 启动jar包脚本

liclvLib_path=./libs
export LD_LIBRARY_PATH=$liclvLib_path

JAR_TARGET=

for file in *.jar; do
  JAR_TARGET+=$file
done

# search and stop specified pid
RESOURCE_NAME=$JAR_TARGET
# Try kill -15 for 5
echo RESOURCE_NAME: $RESOURCE_NAME
tpid=$(ps -ef | grep $RESOURCE_NAME | grep -v grep | grep -v kill | awk '{print $2}')
if [ ${tpid} ]; then
  echo 'ESM Service is allready on Working. Try Stop Process for 5s...'
  kill -15 $tpid
fi
sleep 5
# Is still on working, use kill -9
tpid=$(ps -ef | grep $RESOURCE_NAME | grep -v grep | grep -v kill | awk '{print $2}')
if [ ${tpid} ]; then
  echo 'Kill Process!'
  kill -9 $tpid
else
  echo 'Check and Shutdown old Service finished.'
fi
# recheck the status for this service
tpid=$(ps -ef | grep $RESOURCE_NAME | grep -v grep | grep -v kill | awk '{print $2}')
if [ ${tpid} ]; then
  echo 'ESM Service is still on Running.'
else
  echo 'ESM Service is not on Running now.'
fi
# delete old pid info
rm -f tpid

# java options
JDK_JAVA_OPTIONS=

# JVM Params
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Xms128m"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Xmx512m"

# JMX Params
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Djava.rmi.server.hostname=ip address"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Dcom.sun.management.jmxremote=true"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Dcom.sun.management.jmxremote.port=port"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Dcom.sun.management.jmxremote.ssl=false"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -Dcom.sun.management.jmxremote.authenticate=false"

# Idea Remote
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=port"

# springboot start with nohup
nohup java -jar -Dfile.encoding=UTF-8 $JDK_JAVA_OPTIONS $JAR_TARGET >shell.out 2>&1 &

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值