Cron job

Hi All ,

We have few scripts which uses common environment/path setting variables.
Now instead of putting classpath , framework,java_home ..... etc. in all the script, can we make a file with all common settings which can be envoked by the scripts while running. If yes , say setting file is setEnv.sh, how will we envoke it in script, so that it automatically sets all the env/path.

Thanks in advance for your suggestion.

Regards

Pankaj

You can do what you want. Let's say one of those scripts you have is "myscript.sh" and, as you said, your env is in "setEnv.sh".
Then, add to "myscript.sh" a line like this:

. /path/to/setEnv.sh

You only have to do the same in every script you need to.

Remember that you have to export the variables in "setEnv.sh" just for this to work.

Regards.

Hi Grial

Thanks for your suggestion. Following mail we recieve when I do so

*-*************************************************

Your "cron" job on mfrkuxwbd01
/opt/bea/wls61/config/dev05/batch_automation/batchPolicy/startBatchPolicy.sh > /opt/bea/wls61/config/dev05/batch_automation/batchPolicy/logs/batchPolicy.log

produced the following output:

/opt/bea/wls61/config/dev05/batch_automation/batchPolicy/startBatchPolicy.sh[6]: ./opt/bea/wls61/config/dev05/batch_automation/batch_settings.sh: not found

****************************************************

I am calling setEnv.sh ( here in this case its name is batch_settings.sh ) in my script as follows

. ./opt/bea/wls61/config/dev05/batch_automation/batch_settings.sh.

Regards
Pankaj

Yes, you have put

. ./opt/bea/wls61/config/dev05/batch_automation/batch_settings.sh.

And should be:

. /opt/bea/wls61/config/dev05/batch_automation/batch_settings.sh.

Without the ".", as an absolute path.
Another solution would be using a relative path.
For example, if startBatchPolicy.sh is in /path/to
And batch_settings.sh is also there, that is, both on the same directory, The line should go:

. ./batch_settings.sh

Regards.