I am having trouble getting my Java program to run from cron
. I am able to recreate the problem, using a simple example, as explained below:
In the file /path/to/javaenv.txt
I define my CLASSPATH
variable as follows:
export CLASSPATH=\
"/path/to/dir1":\
"/path/to/dir2":\
"/path/to/dirn":\
"/path/to/jar1":\
"/path/to/jar2":\
"/path/to/jarn"
From the command line I am able to execute the Java program quite easily by doing something like this:
source "/path/to/javaenv.txt" && java pkgName.ClassName cmd-line-params > /tmp/test-$(date +%s).txt 2>&1
However, the job does not get executed from cron
, eventhough my crontab
has the following entry:
* * * * * source "/path/to/javaenv.txt" && java pkgName.ClassName cmd-line-params > /tmp/test-$(date +%s).txt 2>&1