#!/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} &
如果用-jar,就不能用-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 [ -f $libfile ] ; then CLASSPATH=$libfile:${CLASSPATH} fi done for libfile in ${BASE_DIR}/*.jar ; do if [ -f $libfile ] ; then CLASSPATH=$libfile:${CLASSPATH} fi done CLASSPATH=${BASE_DIR}:${CLASSPATH} nohup "java" ${JAVA_OPTS} -server -cp ${CLASSPATH} ${START_CLASS} &
使用nohup是为了避免账户注销发送的hup信号,会导致该账户调用的程序注销,使用nohup会忽略此信号。
语句最后的&表示该进程在后台运行