我编写了以下脚本来运行 Java 类:
#!/bin/sh
# Set this to the directory where the JDK is installed
JAVA_HOME=/opt/weblogic-9.2mp1/java1.5
# Set this to the path to the JAR file containing the JMS classes
# (for example, the path to the weblogic.jar file)
JMS_JAR=/opt/weblogic-9.2mp1/weblogic92/server/lib/weblogic.jar
# Specify the name of the <ServerNode> node in ASC
SERVER_NODE_NAME=TDCPublisher
# If you have custom save beans and load beans in your own JAR file,
# append your JAR file to this variable.
CLASSPATH=$JMS_JAR:$JAR_DIR/ClfyCore.jar:$JAR_DIR/awsi.jar:$JAR_DIR/acfglib.jar:$JAR_DIR/jaxen-1.1-beta-9.jar:$JAR_DIR/Amdocs
Aif.jar:$JAR_DIR/AmdocsProcMgrBase.jar:$JAR_DIR/AmdocsSvcCommon.jar:/apps/fasigw/test/fasigwApp/custom/FASIGWLink.jar
export CLASSPATH
# Set the path for accessing the JDK directory
PATH=$JAVA_HOME/bin:$PATH
export PATH
checkJDK()
{
if [ ! -f $JAVA_HOME/bin/java ]; then
echo "Error: $JAVA_HOME/bin/java not found."
echo "Please edit this script so that the JAVA_HOME variable"
echo "points to the root directory of your JDK installation."
return 1
fi
return 0
}
checkClassPath()
{
if [ ! -f $JAR_DIR/ClfyCore.jar ]; then
echo "Error: $JAR_DIR/ClfyCore.jar not found."
echo "Please edit this script so that the JAR_DIR variable"
echo "points to the directory where ClfyCore.jar and the other"
echo "ClarifyCRM JAR files are located."
return 1
fi
return 0
}
main()
{
checkJDK
if [ $? != 0 ]; then
return 1
fi
checkClassPath
if [ $? != 0 ]; then
return 1
fi
$JAVA_HOME/bin/java -Djava.security.auth.login.config=/apps/fasigw/test/AmdocsCRM7.5/AmdocsCRMApplication/conf/auth.conf -
cp ${CLASSPATH} com.clarify.daevtpub.ClarifyEventProcessor sa cleartest -pl ${SERVER_NODE_NAME} -ShowStatus -Debug -OutFile /
apps/fasigw/test/logs/DataChangeLog.log
return 0
}
main $*
但面临的问题是 - 一旦我退出服务器并再次登录,虽然我可以看到该进程正在使用命令ps -ef运行,但该类没有被执行。我需要再次手动开始运行脚本。如何避免这种情况并确保脚本在后台持续运行?脚本名称是 startEventProcessor,我执行以下命令来运行脚本:
./startEventProcessor &