Shell script starts java

#!/usr/bin/env bash BASE_DIR=(pwd) LIB="{BASE_DIR}/lib/" JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8" START_CLASS="com.abc.cde.aaaserver" nohup java {JAVA_OPTS} -server -classpath "{LIB}/*:{LIB}/droolsRuntime/*:eiServer.jar"{START_CLASS} &

If -jar, can not be used -cp (-classpath) #! / Bin / sh

BASE_DIR=(pwd) LIB="{BASE_DIR}/lib/" JAVA_OPTS=" -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=1024k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/mtdperf.hprof -server -Dfile.encoding=UTF-8" START_CLASS="com.tencent.bugly.EiServer"

echo ${LIB}

for libfile in {LIB}/*.jar ; do if [ -flibfile ] ; then CLASSPATH=libfile:{CLASSPATH} fi done

for libfile in {BASE_DIR}/*.jar ; do if [ -flibfile ] ; then CLASSPATH=libfile:{CLASSPATH} fi done

CLASSPATH=BASE_DIR {}:{CLASSPATH} nohup "java" {JAVA_OPTS} -server -cp{CLASSPATH} ${START_CLASS} &

Use nohup to avoid account cancellation hup send a signal, it will lead to the cancellation of the account calling program, use the nohup ignores this signal.

The final statement & indicates that the process is running in the background

Guess you like

Origin blog.csdn.net/weixin_33814685/article/details/91394217