shell运行java/Jar 脚本

1.Shell执行/调用Java/Jar程序

#!/bin/bash
JAVA_HOME="$HOME/jdk"
BASE_DIR=`dirname $0`
if [ "$BASE_DIR" = '.' ]
then
    BASE_DIR=`pwd`
fi
PROCESS_HOME=`dirname $BASE_DIR`
MY_DIR="$PROCESS_HOME/gasarchiveprocess"
RUN_DIR="$MY_DIR/rundir"
LIB_DIR="$MY_DIR/lib"
JVM_OPTS="-server -Xms1024m -Xmx1024m  -DCONFIG_NAMESPACE=000 -DGASARCHIVEPROCESS"

LANG=zh_CN.UTF-8
JRE_HOME="$JAVA_HOME/jre"
CLASSPATH="$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/rt.jar:$JRE_HOME/charsets.jar"

MYCP="$LIB_DIR/c3p0-0.9.1.2.jar:$LIB_DIR/c3p0-oracle-thin-extras-0.9.1.2.jar:$LIB_DIR/commons-beanutils-1.7.0.jar:$LIB_DIR/commons-chain-1.1.jar:$LIB_DIR/commons-codec-1.3.jar:$LIB_DIR/commons-collections-3.2.1.jar:$LIB_DIR/commons-configuration-1.0.jar:$LIB_DIR/commons-dbcp.jar:$LIB_DIR/commons-digester-1.6.jar:$LIB_DIR/commons-discovery.jar:$LIB_DIR/commons-email-1.1.jar:$LIB_DIR/commons-fileupload-1.2.2.jar:$LIB_DIR/commons-httpclient-3.1-rc1.jar:$LIB_DIR/commons-io-2.0.1.jar:$LIB_DIR/commons-jexl-1.1.jar:$LIB_DIR/commons-lang-2.3.jar:$LIB_DIR/commons-logging-1.1.1.jar:$LIB_DIR/commons-net-1.4.1.jar:$LIB_DIR/commons-pool.jar:$LIB_DIR/commons-validator.jar:$LIB_DIR/daopub1.0.jar:$LIB_DIR/gascommon.jar:$LIB_DIR/gasdao.jar:$LIB_DIR/ibatis-2.3.0.677.jar:$LIB_DIR/ibsspub1.0.jar:$LIB_DIR/log4j-1.2.15.jar:$LIB_DIR/oracle10g.jar:$LIB_DIR/slf4j-api-1.5.0.jar:$LIB_DIR/slf4j-log4j12-1.5.0.jar:$LIB_DIR/spring-beans.jar:$LIB_DIR/spring-mock.jar:$LIB_DIR/spring-security-core-2.0.3.jar:$LIB_DIR/spring-webmvc-struts.jar:$LIB_DIR/spring.jar:$LIB_DIR/sysmgr1.5_zx.jar:$LIB_DIR/sysmgrzxdao.jar:$LIB_DIR/wlfullclient.jar"
MYCP="$MYCP:$MY_DIR/gasarchiveprocess.jar:$MY_DIR/config:$MY_DIR"

export JAVA_HOME;
export JRE_HOME;
export CLASSPATH;
export LANG;

echo $MYCP
echo $PROCESS_HOME
echo $MY_DIR
echo $JAVA_HOME
echo $CLASSPATH

cd $RUN_DIR
java $JVM_OPTS -DDACS_HOME="$MY_DIR" -cp "$MYCP" com.xxx.ArchiveProcessConsole
echo $! > pidfile


2.Shell kill进程

#!/bin/bash
ps -ef|grep java|grep GASARCHIVEPROCESS|awk '{print $2}'|xargs kill -9
posted @ 2015-07-13 09:21  songjinduo  阅读(8466)  评论(0编辑  收藏  举报