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 &
Linux shell 启动jar包脚本
于 2022-03-02 21:54:21 首次发布