http://m.egloos.zum.com/ilovekms/v/1085447

배치 프로그램 실행시 start,stop,alive shell script

start.sh

#!/bin/sh
export WORK_HOME=/wrk0.d/batch/TxPayBatch
export CLASSPATH=.
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-beanutils-bean-collections.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-beanutils-core.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-beanutils.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-collections-3.1.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-dbcp-1.2.1.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-dbutils-1.0.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-digester-1.7.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-lang-2.1.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-logging-api.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/commons-logging.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/jconn2.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/log4j-1.2.12.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/lib/ojdbc14.jar
export CLASSPATH=$CLASSPATH:"$WORK_HOME"/TxCred.jar
echo javac -d . -classpath "$CLASSPATH" Main.java
javac -d . Main.java
nohup java -Xms128m -Xmx521m Main 2> /dev/null &
echo $! > txCred.pid    


                               
stop.sh

pid=`cat txCred.pid`
if [ "$pid" -lt 3 ] ; then
( echo "Batch was not running."  ) &
else
kill $pid
#rm $pid
rm -f txCred.pid
( echo "Batch stopped."  ) &
fi


alive.sh

pid=`cat txCred.pid`
ps -ef | grep java | grep $pid | awk '{print $2}'
Posted by 張's blog
,