LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Suse/Novell
User Name
Password
Suse/Novell This Forum is for the discussion of Suse Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 03-06-2006, 04:30 PM   #1
bret
Member
 
Registered: Apr 2005
Location: SLC, Utah
Distribution: RHEL 4, RHEL 5
Posts: 54

Rep: Reputation: 16
CRON doesn't retain $PATH of user


For some reason when my CRON runs for my Oracle id, the environment variables don't appear to get passed. As an example, if I log in as Oracle and run a script that does the following

echo $PATH > path.txt

then I am returned the following:

/usr/local/bin:/oracle/product/9.2.0.6/bin:home/oracle/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/opt/gnome/bin:/opt/kde3/bin

But...

When I set up cron for Oracle, then the script does the following (output from echo $PATH

/usr/bin:/bin

Why isn't cron picking up Oracle's correct PATH? The script isn't passing my correct env either. Any ideas?

Thanks in advance,

Bret
SLC, UT
 
Old 03-06-2006, 04:39 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,021

Rep: Reputation: 125Reputation: 125
Depending on the version of cron that you run, it probably has a cut down environment to run your jobs in. Dillon's cron for example, only keeps the USER, HOME, and SHELL variables when running a user's job.

Using the full path to the commands used in the script and exporting the required environment variables in the script should allow it to run.
 
Old 03-06-2006, 10:03 PM   #3
bret
Member
 
Registered: Apr 2005
Location: SLC, Utah
Distribution: RHEL 4, RHEL 5
Posts: 54

Original Poster
Rep: Reputation: 16
Hi Steve,

Thanks for the update. I'll try it.
 
Old 03-09-2006, 10:35 AM   #4
bret
Member
 
Registered: Apr 2005
Location: SLC, Utah
Distribution: RHEL 4, RHEL 5
Posts: 54

Original Poster
Rep: Reputation: 16
We have many scripts that will need to be ported from HP-UX. The problem is that we don't want to modify every script with the environment variable information that they each need. Obviously, the cron env is different from shell environment of the oracle user (or any user for that matter). Why is this, and how do I make the cron env to be the same as the user's shell env?

As an example...
If I do an 'env' in cron, I only get:
SHELL
PATH
PWD
HOME
SHLVL
LOGNAME
_

When I do an `env` in my shell, I get about 70 variables. Is there any way to get these variables visible in my cron? I can't get any of my scripts to run in cron. Thanks.

Bret Goodfellow
SLC, UT
 
Old 03-09-2006, 01:04 PM   #5
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,021

Rep: Reputation: 125Reputation: 125
Unfortunately, not with the version of cron I'm using. It may be possible to create a file that holds your environment variables and source that at the top of each script. It does mean modifying each script still, but you could do it with sed.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suse -- How to export user PATH to super user? w0262 Linux - Newbie 5 01-10-2006 09:39 PM
How do I retain the PATH in the root account even when I switch to root using su? thearchitect Linux - Newbie 1 08-13-2005 12:02 AM
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
Changing the Cron Path elconde Linux - General 0 11-21-2001 05:36 PM


All times are GMT -5. The time now is 03:46 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration