Running scripts within scripts from cron

Hi all,

I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so.

0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log
The checkstatus.sh scripts looks like this.

#!/bin/ksh

echo Test runs `date`

. ~/.bash_profile

cd /u01/home/bin

./java_env.ksh

./trigger_process.ksh checkstatus

The java_env.ksh sets up various variables like JAVA_HOME and LOG_FILE using an export <VARIABLE NAME> commands.

The trigger_process.ksh is a generic script which calls a java class which is passed into it.

When I run the checkstatus.sh script from the shell it works fine however when it runs from cron it doesn't. The variables exported in ./java_env.ksh are not available to the trigger_process.ksh script.

Is there a way to run the cron job so that the variables are available globally?

source the java_env.ksh script...

if the checkstatus script works from your command line then the contents of the varaibles in java_env.ksh were already defined in your process before you even entered the name 'checkstatus.sh' on the command line. You have to source the java_env.ksh in order to make the env variables available.

Thanks Jim but I'm not sure I understand you. The variables aren't available from my shell they are being created by the java_env.ksh script.

Not sure what you meant by

"You have to source the java_env.ksh in order to make the env variables available."

Thanks for your help.

Start the script with a dot and a space in front of the scriptname:

. ./java_env.ksh

Regards

Cheers dude,

Thats exactly what I needed to do.