Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: oraenv and cron
In article <8r0dig$pju$1_at_nnrp1.deja.com>,
Joseph T <jthvedt_at_my-deja.com> wrote:
> In article <8qvpgh$7mc$1_at_nnrp1.deja.com>,
> oratune_at_aol.com wrote:
>
> [edit]
>
> > > > > Why is it that if I run a shell script containing oraenv from
cron
> > > > > as the
> > > > > oracle user, it doesn't work; but if I have root run it in
cron
> > > > > with su - oracle -c script_name, it runs?
> > >
>
> [edit]
>
> > cron does not invoke any shell startup features, such
> > as .profile, .bash_profile. .login, .cshrc, etc., so all the cron
job
> > has as far as environment is the default /etc/profile settings.
Since
> > you are running an interactive .profile you will want to create a
> > version of that, possibly named .cron_profile, that you can invoke
from
> > cron jobs without the interactive components. Yes, this will
> > necessitate multiple .cron_profile files (to deal with the multiple
> > SID's) or you'll need to make the .cron_profile as universal as
> > possible and set the ORACLE_SID value in each cron job.
> >
> > When you run as root and invoke "su - oracle -c ..." you set the
> > environment for oracle without the interactive commands; the "su -
> > oracle" does this. Unfortunately cron does not work in this manner
and
> > you must set the environment in the scripts.
>
> Not to beat a dead horse, but isn't oraenv supposed to do that very
> thing? It sets $PATH; it sets $ORACLE_SID; it sets $ORACLE_HOME. Or at
> least it does when not run from cron. What is there about a generic,
> no-.profile, cron environment that prevents oraenv from doing its job?
>
> >
> > --
> > David Fitzjarrell
> > Oracle Certified DBA
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> --
> Joseph Thvedt
> jthvedt_at_my-deja.com
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
As I said before, cron does NOT set environment, including modified PATH's. Since the PATH set when 'oracle' runs cron jobs is the default PATH from /etc/profile local settings are not available, and one of those local settings is a modified path to point to various and sundry directories not included with the default PATH. The cron jobs run under the 'oracle' id cannot find the oraenv script so it can't do its job. Try explicitly pathing the oraenv line in your cron scripts so 'oracle' can run them. Also, as I said previously, the "su - oracle -c" sets the environment as though 'oracle' had actually logged into the system; cron does not. This is why the scripts, run by 'root', can find the oraenv script and the cron jobs run by 'oracle' cannot.
-- David Fitzjarrell Oracle Certified DBA Sent via Deja.com http://www.deja.com/ Before you buy.Received on Thu Sep 28 2000 - 16:47:44 CDT
![]() |
![]() |