Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 如何确保UNIX脚本连续运行?_Shell_Unix - Fatal编程技术网

Shell 如何确保UNIX脚本连续运行?

Shell 如何确保UNIX脚本连续运行?,shell,unix,Shell,Unix,我为运行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=/

我为运行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 $*
使用:


无需显式选中
$?
。只要写:
if!checkJDK;然后返回1;fi
此外,即使此脚本不使用参数,您也应该养成正确引用的习惯,并使用:
main“$@”
而不是
main$*
./startEventProcessor &
nohup ./startEventProcessor &