2

I am executing a script through cron using the below command:

*/10 * * * * cd  /nas/app/someFolder/psox; ./RunPSOX.sh >> /tmp/trial.log 2>&1

This is being executed by root user. All PATH and JAVA_HOME have been set at the root level and exported. JDK 1.6 is being used.

The script also has the PATH set inside it at the beginning (have tried both absolute and relative path), the JAVA_HOME and CLASSPATH too. I have added the "env" and "java -version" into the script before the logic.

The script fails to work through cron but works when triggered manually. The reason is that the jdk version at shell level is jdk 1.6 but when the script is executed through cron, it is picking up the jdk version as 1.4 and throws a Java error. I have checked the associated property files and there is no reference of jdk 1.4 anywhere.

Please advise, where else I need to check for the jdk version and make it consistent as jdk 1.6 for both shell and the script when running through cron.

3
  • Inside RunPSOX.sh, you are explicitly setting the path? Could you paste in the PATH setting as an example? Things to check: Make sure your java directory is placed on the front of the PATH, not the end. Also make sure you're exporting it. also, check the output from "/usr/bin/update-alternatives --display java" on the command line.
    – ELadner
    Jun 14, 2012 at 19:09
  • OP hasn't signed on in +5 years. OP never responded to suggestions from other user. Ubuntu version is End of Life. VTC as not reproducible. Jul 17, 2017 at 4:53
  • What's the content of ./RunPSOX.sh? Jul 17, 2017 at 9:53

0

Browse other questions tagged .