Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

*/10 * * * * cd  /nas/app/someFolder/psox; ./ >> /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.

share|improve this question
Inside, 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 '12 at 19:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.