#!/bin/bash ### 切换到工作目录 bin=$(cd `dirname ${0}`;pwd) cd ${bin} echo "bin [${bin}] .." ### 参数设置 process="RCrNew" LOGPATH="/web/logs" day=$(date +%Y%m%d) #instance=$(echo ${bin}|awk -F'/' '{print $NF}') ### 如果程序已存在,先退出再执行 #if [ $(ps -ef|grep -v grep|grep ${process}|grep ${instance}|grep -Ewv "less|tail|tailf"|wc -l) -ne 0 ] if [ $(ps -ef|grep -v grep|grep ${process}|grep -Ewv "less|tail|tailf"|wc -l) -ne 0 ] then ps -ef|grep -v grep|grep ${process}|grep -Ewv "less|tail|tailf" echo "${process} instance: ${instance} is exists,Please kill it and run agin" exit fi ### JAVA相关参数设置 MAINCLASS="com.yyyy.app.RCNew" JAVA="$JAVA_HOME/bin/java" JAVA_OPTS="-server -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=128m " JARS1=`find -L "${bin}/dependency" -name "*.jar" -printf '%p:'` JARS2=$(ls -rt *jar|tail -1) JARS=${JARS1}${JARS2} echo -e "JARS2: [ ${JARS2} ] mainClass: [ ${MAINCLASS} ]" # echo -e "JARS1: [ ${JARS1} ] JARS2: [ ${JARS2} ] mainClass: [ ${MAINCLASS} ]" # echo -e "JARS: [ ${JARS} ]" ### 执行程序 nohup ${JAVA} ${JAVA_OPTS} -cp ${JARS} ${MAINCLASS} 1>/dev/null 2>&1 & if [ $? -eq 0 ] then echo "${process} run successful" else echo "${process} run fail" fi
1 #!/bin/bash 2 3 LIB=$(dirname ${0}) 4 echo "LIB [${LIB}] .." 5 6 JARS=`find -L "${LIB}" -name '*.jar' -printf '%p:'` 7 echo "JARS [${JARS}] .." 8 9 $JAVA_HOME/bin/java -cp ${JARS} com.lxw1234.hive.orc.TestORCWriter $*
#!/bin/bash VERSION=$1 MAINCLASS=$2 LIB=$(cd `dirname ${0}`;pwd) cd ${LIB} echo "LIB [${LIB}] .." JARS1=`find -L "${LIB}/dependency" -name "*.jar" -printf '%p:'` JARS2=${JARS}`find -L "${LIB}" -maxdepth 1 -name "*${VERSION}*.jar"` JARS=${JARS1}${JAR2} echo -e "JARS1: [ ${JARS1} ] JARS2: [ ${JARS2} ] mainClass: [ ${MAINCLASS} ]" $JAVA_HOME/bin/java -cp ${JARS} ${MAINCLASS} $*