shell script load jar files and hang

2019-08-27 03:23发布

问题:

Good day,

I have a shell script, which will load some jar files first before proceed to do its job. The following is part of my shell script code to load jar files:

for f in `find $BASEDIR/lib -type f -name "*.jar"` 
do 
  CLASSPATH=$CLASSPATH:$f
  echo Getting  jar file : $f... >> $LOG
done

This is working fine when I trigger this through Crontab, I set a time in crontab and let it trigger automatically, and its work without any error.

However, I having some problem when I trigger this shell script through application run time. Here is my java code to trigger this shell script:

try {
  p = Runtime.getRuntime().exec("myShell.sh");
  log.debug("Successfully invoked batch.");
} catch (Exception ex) {

  log.info("Hit error : "
      + ex.getMessage());

  return false;
}

I checked the log that I put in the shell script, and found that its hang when trying to getting "xstream-1.4.9.jar" (during run time call). But crontab call have no issue.

And another weird thing is, I have 2 same environment, which is environment 1 and environment 2, and this issue only happen in environment 2, checked through all the permission, they are the same.

Can anyone advise how I can continue to troubleshoot on this?