Linux run.sh java jar包运行脚本

先查询是否已经存在进程,如果存在先杀掉在启动。

#!/bin/bash
set -o nounset
set -o errexit
export LANG=zh_CN.UTF-8
process_id=$(ps -ef | grep es2es-0.0.1-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}')
[ $process_id ] && kill -9 ${process_id}
sleep 17
/idoc/jdk/jdk-10.0.2/bin/java -version


export JAVA_HOME="/idoc/jdk/jdk-10.0.2"
export PATH=${JAVA_HOME}/bin:${PATH}
#java -version


#TSTR=`date +"%Y%m%d%H%M%s"`
if [ -z ${JAVA_OPTS+x} ]; then JAVA_OPTS=; else echo "Original JAVA_OPTS: ${JAVA_OPTS}"; fi
#JAVA_OPTS="${JAVA_OPTS} -d64 -server"
#JAVA_OPTS="${JAVA_OPTS} -DDEBUG.MONGO=true -DDB.TRACE=true"
#. gc_info.sh
#. gc_cms.sh
#JAVA_OPTS="${JAVA_OPTS} -Dalbacore.gc.interval.ms=3000"
#JAVA_OPTS="${JAVA_OPTS} -Dalbacore.io.parallelism.ratio=2"
JAVA_OPTS="${JAVA_OPTS} -Xms12g -Xmx12g -Xss100m"
#JAVA_OPTS="${JAVA_OPTS} -Djava.util.concurrent.ForkJoinPool.common.parallelism=16"
#JAVA_OPTS="${JAVA_OPTS} -agentpath:/opt/jprofiler/bin/linux-x64/libjprofilerti.so=port=18999"
#JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=18089 -Ddebug.parallel=false"


## application configuration
echo JAVA_OPTS:                 ${JAVA_OPTS}


RUNABLE_CP="/xxx/xxx/es2es-0.0.1-SNAPSHOT.jar:/xxx/xxx/dependency/*"
echo Java Classpath:    ${RUNABLE_CP}


echo "==>Java OPTS: ${JAVA_OPTS}"
RUNABLE_CMD="/xxx/jdk/jdk-10.0.2/bin/java ${JAVA_OPTS} -cp ${RUNABLE_CP} data.batch.es2es.Mysql2ES  > /xxx/pump/log3.txt"
echo "==>Command to be Run: ${RUNABLE_CMD}"
echo "Running...."
${RUNABLE_CMD}
上一篇:Python爬虫+可视化教学:爬取分析宠物猫咪交易数据


下一篇:Tomcat设置远程debug