shell 执行jar 的命令

#!/bin/sh
##############
#判断是否程序已启动
jappname='Test'
mainclasspath="com.company.commontest.test"
javaps=`jps`
i=0
psid=0
for psresult in $javaps
do
let cur=i%2
if [ $cur -eq 0 ]; then
psid=$psresult
else
if (test "$psresult" = "$jappname")
then
echo "程序"$jappname"[pid="$psid"]已经启动!"
exit 0
fi
fi
let i++;
done
#引入依赖类库到类路径
classpath="."
classpath="$classpath:commontest-0.0.1-SNAPSHOT.jar"
classpath="$classpath:spring-context.xml"
classpath="$classpath:log4j.properties"
pathtmp=''
for jarpath in `ls lib/*.jar`
do
classpath=$classpath:$jarpath
done
echo $classpath
echo $mainclasspath
nohup java -server -XX:-UseGCOverheadLimit -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -classpath $classpath $mainclasspath >std.out 2>&1 &

posted @ 2015-12-16 13:34  doo  阅读(3694)  评论(0编辑  收藏  举报