LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting environment variuables (https://www.linuxquestions.org/questions/linux-newbie-8/setting-environment-variuables-714775/)

rushenas 03-27-2009 02:53 AM

Setting environment variuables
 
Hi
I've written a Java program, which connects to an Oracle database, and run some queries. The problem is, it can not find the OCI library which is located in ${ORACLE_HOME}/lib, so I need to set an environment variable like this:
Code:

export LD_LIBRARY_PATH=${ORACLE_HOME}/lib
I have put this in /etc/profile.local (I have a SuSE Linux Enterprise Server 10). The problem is when I want to run the program via the cron. It can not find the LD_LIBRARY_PATH. So how can I set the environment variable, and guide cron to find it?

zhjim 03-27-2009 03:13 AM

Checkout the file "/etc/crontab". Inside you will find the PATH settings for all the cronjobs. Try if the java programm runs if you fill in the enviorment variable.

If this doesn't work just make a little wrapper script for cron.

Code:

!#/bin/bash
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib
/path/to/the/java/prog

Set the right permission, namly execution, and fire it up from crontab or one of the /etc/cron.* directories

Regards Zhjim

rushenas 03-27-2009 08:18 AM

Unfortunately, it doesn't work. When I run application from command line, it works great. But when it comes to cron, it doesn't work, just because LD_LIBRARY_PATH doesn't set correctly...

zhjim 03-30-2009 06:56 AM

Ok. Did you try the wrapper script? Maybe it's not the LD_LIBRARY env var alone?

maxy7710 03-30-2009 07:10 AM

Can u share u r cron script

or else u can make entries of export LD_LIBRARY........... in u r script, which will eventually set LD_LIBRARY when the script runs.

ex:-

vim /oracle/test.sh
LD_LIBRARY_PATH=xyz
export LD_LIBRARY_PATH
ur required commands



crontab -e

00 02 * * * sh /oracle/test.sh


i hope this helps

john test 03-30-2009 08:01 AM

Quote:

Originally Posted by rushenas (Post 3489520)
Unfortunately, it doesn't work. When I run application from command line, it works great. But when it comes to cron, it doesn't work, just because LD_LIBRARY_PATH doesn't set correctly...


Is there a difference in permissions cli vs. cron?
perhaps you are root in one instance and user in the other?


All times are GMT -5. The time now is 11:51 PM.