shell 运行 jar 文件脚本
linux 下运行 java jar 的 shell 脚本#!/bin/shbasepath=$(cd `dirname $0`; pwd)cd $basepathcd ../PWD=`pwd`echo $PWDfor i in lib/*; do CLASSPATH=$PWD/$i:"$CLASSPATH";done
·
linux 下运行 java jar 的 shell 脚本
#!/bin/sh
basepath=$(cd `dirname $0`; pwd)
cd $basepath
cd ../
PWD=`pwd`
echo $PWD
for i in lib/*;
do CLASSPATH=$CLASSPATH:$PWD/$i
done
export CLASSPATH=$CLASSPATH:$PWD/prespider.jar
java -Dfile.encoding=UTF-8 -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:/tmp/javagc.log -XX:+HeapDumpOnOutOfMemoryError $@
#!/bin/sh
export JAVA_HOME=/usr/java/jdk1.6.0_38
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
echo "start"
basepath=$(cd `dirname $0`; pwd)
cd $basepath
cd ../
PWD=`pwd`
for i in lib/*;
do CLASSPATH=$CLASSPATH:$PWD/$i
done
export CLASSPATH=$CLASSPATH:$PWD/maprHbase.jar
className='com.ysq.mrhb.example.SubmitHbmrJob'
parameter=("/home/output/hbase/" "/home/output/hbase")
echo ${parameter[*]}
java -Dfile.encoding=UTF-8 -Xmx1024M $className ${parameter[*]} > $PWD/runtimeLogs/xtreamTest.log 2>&1
运行之前判断是否正在执行
#!/bin/sh
nowPath=$(cd `dirname $0`; pwd)
cd $nowPath
cd ../
basePath=`pwd`
className='com.ysq.test.TestRun'
parameter=$@
function javaRun(){
echo "start"
for i in lib/*; do
CLASSPATH=$CLASSPATH:$basePath/$i
done
#base jar
for i in target/*; do
CLASSPATH=$CLASSPATH:$basePath/$i
done
cd ./target/
java -Dfile.encoding=UTF-8 -Xmx256M $className ${parameter[*]} > $basePath/runtimeLogs/runOut.log 2>&1 &
}
count=`ps -ef | grep $className | grep -v "grep" | wc -l`
if [ $count -gt 0 ];then
currentThread=`ps -ef | grep $className | grep -v "grep"`
echo "$className has been started, please stop it first : "
echo " $currentThread"
else
#run java
javaRun
fi
更多推荐
已为社区贡献2条内容
所有评论(0)