LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2009, 03:53 AM   #1
rushenas
Member
 
Registered: May 2005
Posts: 34

Rep: Reputation: 15
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?
 
Old 03-27-2009, 04:13 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
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
 
Old 03-27-2009, 09:18 AM   #3
rushenas
Member
 
Registered: May 2005
Posts: 34

Original Poster
Rep: Reputation: 15
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...
 
Old 03-30-2009, 07:56 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Ok. Did you try the wrapper script? Maybe it's not the LD_LIBRARY env var alone?
 
Old 03-30-2009, 08:10 AM   #5
maxy7710
Member
 
Registered: Jan 2008
Location: Mumbai, india
Distribution: REDHAT, FEDORA,SUSE, UBUNTU, ORACLE ENTERPRISE LINUX & SOLARIS 10
Posts: 130

Rep: Reputation: 17
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
 
Old 03-30-2009, 09:01 AM   #6
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
Quote:
Originally Posted by rushenas View Post
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting environment variable madani Linux - Software 5 03-06-2009 01:15 PM
Setting up the environment Mathiasdm Linux From Scratch 4 04-09-2006 09:58 AM
Environment variables setting... simjii SUSE / openSUSE 4 11-19-2005 08:50 PM
Setting up a environment variable Hiper1 Linux - Newbie 3 03-08-2005 09:43 AM
Need help setting environment variables. cottonmouth Linux - Newbie 3 12-09-2004 05:54 PM


All times are GMT -5. The time now is 09:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration