標籤:shell指令碼啟動程式
我們都知道jvm本身提供了很多的命令供使用者調用,有時候我們需要使用這些命令寫一些指令碼來執行我們的程式,首先說下以下指令碼的目錄結構:
bin 指令碼存放處
lib 依賴的jar包存放處
conf 依賴的設定檔存放處
打好的可運行jar放在目前的目錄
#!/bin/bashexport JAVA_HOME=/usr/javaexport PATH=$JAVA_HOME/bin:$PATH#-------------------------------------------------------------------# Mb Bootstrap Script #-------------------------------------------------------------------function main(){ # find Mb home. CURR_DIR=`pwd` cd `dirname "$0"`/.. RESV_HOME=`pwd` cd $CURR_DIR if [ -z "$RESV_HOME" ] ; then echo echo Must set RESV_HOME echo exit 1 fi pc=`ps -ef | grep "ThreadMore $1" | wc -l ` echo "process count:$pc" if [[ $pc -gt 1 ]]; then echo "last job havent finish,exit." exit 1 fi execute $1 $2}function execute(){ for i in $RESV_HOME/lib/*.jar; do CLASSPATH=$i:$CLASSPATH; done #echo RESV_HOME=$RESV_HOME CLASSPATH=$RESV_HOME/conf:$RESV_HOME/smack.jar:$CLASSPATH DEBUG_INFO=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" DEBUG="" if [ "$1" = "load" ] then MAIN_CLASS="www.smack.ThreadLocal $1"; DEFAULT_OPTS="-server -Xms10G -Xmx10G " ; else if [ "$1" = "check" ] then MAIN_CLASS="www.smack.ThreadLocal "; DEFAULT_OPTS="-server -Xms2G -Xmx2G" ; else MAIN_CLASS="www.smack.ThreadLocal $1 $2"; DEFAULT_OPTS="-server -Xms2000m -Xmx2000m -Xss128k" ; fi fi DEFAULT_OPTS="$DEFAULT_OPTS -Djava.awt.headless=true -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=10.10.10.7" DEFAULT_OPTS="$DEFAULT_OPTS -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=60" DEFAULT_OPTS="$DEFAULT_OPTS -DMB.home=\"$RESV_HOME\"" echo java $DEBUG $DEFAULT_OPTS -classpath $CLASSPATH $MAIN_CLASS java $DEBUG $DEFAULT_OPTS -classpath $CLASSPATH $MAIN_CLASS}main "4000" "40"
本文出自 “陳硯羲” 部落格,請務必保留此出處http://chenyanxi.blog.51cto.com/4599355/1559651
shell指令碼啟動程式