Re: How I run a shell script from the scheduler on 10.2.0.2.0 ?

  • From: "LS Cheng" <exriscer@xxxxxxxxx>
  • To: owensmith99@xxxxxxxxx
  • Date: Sat, 8 Sep 2007 10:15:54 +0200

Befoe modifying did you check the permissions of files you did this?

chown root $ORACLE_HOME/bin/extjob
chmod 4750 $ORACLE_HOME/bin/extjob
chown root $ORACLE_HOME/rdbms/admin/externaljob.ora
chmod 640 $ORACLE_HOME/rdbms/admin/externaljob.ora

because by default those are the permissions, you should not have to do that
manually

thanks

--
LSC

On 9/8/07, Owen Smith <owensmith99@xxxxxxxxx> wrote:
>
> Oracle People,
>
> Ravi's comments looked promising.
>
> I looked for root.sh
>
> bash sol oracle ~ 23 $
> bash sol oracle ~ 23 $
> bash sol oracle ~ 23 $ cd $ORACLE_BASE
> bash sol oracle ~ 24 $ find . -name root.sh -print
> ./product/10r2/root.sh
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
>
> I looked for evidence that it alters permissions of files related to
> external jobs:
>
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $
> bash sol oracle ~ 25 $ grep CHOWN ./product/10r2/root.sh
> CHOWN=/bin/chown
>       $CHOWN $ORACLE_OWNER $LBIN/`$ECHO $f | $AWK -F/ '{print $NF}'`
> 2>&1 2>> $LOG
> $CHOWN $ORACLE_OWNER ${ORATAB}
> CHOWN="/usr/bin/chown"
>   CHOWN=/bin/chown
> $CHOWN root $ORACLE_HOME/bin/nmo
> $CHOWN root $ORACLE_HOME/bin/nmb
> $CHOWN root  /var/tmp/.oracle
> $CHOWN root  /tmp/.oracle
> bash sol oracle ~ 26 $
> bash sol oracle ~ 26 $
> bash sol oracle ~ 26 $
>
>
> I did not expect that it would.  I'm diligent about following
> instructions when I install oracle.
>
> Perhaps root.sh was enhanced by a quarterly patch.  I'm on an eval
> license; I have
> no access to support or quarterly patches.
>
> Anyway, I took these steps to follow Ravi's suggestions:
>
> -emctl stop agent
> -emctl stop dbconsole
> -lsnrctl stop
> -SHUTDOWN IMMEDIATE
>
> chown root $ORACLE_HOME/bin/extjob
> chmod 4750 $ORACLE_HOME/bin/extjob
> chown root $ORACLE_HOME/rdbms/admin/externaljob.ora
> chmod 640 $ORACLE_HOME/rdbms/admin/externaljob.ora
>
> -STARTUP
> -lsnrctl start
> -emctl start agent
> -emctl start dbconsole
>
>
> Result?
>
> It worked.
> I can now run shell scripts from the scheduler.
> Also I'm pleased that the scripts run as the user I specify in
> $ORACLE_HOME/rdbms/admin/externaljob.ora
>
> For security reasons I don't want external jobs run as a privileged
> user like oracle or root.
>
> Thanks Ravi!
>
> -Owen
>
>
> On 9/7/07, Owen Smith <owensmith99@xxxxxxxxx> wrote:
> > Hello people,
> >
> > I should have added this bit of information:
> >
> > "The script runs fine from oracle's crontab."
> > "The script runs fine from a shell owned by oracle."
> >
> > I'm getting responses telling me to check my env variables and
> permissions
> > which would be helpful to a UNIX novice.
> >
> > I have a feeling that no one is using the scheduler to run RMAN scripts.
> >
> > Tim Hall suggested I take a close look at these files:
> >
> > $ORACLE_HOME/rdbms/admin/externaljob.ora
> > $ORACLE_HOME/bin/extJob
> >
> > Currently I'm setup like this:
> >
> >
> > bash sol root /h/oracle/product/10r2/bin 31 #
> > bash sol root /h/oracle/product/10r2/bin 31 # ll
> > $ORACLE_HOME/rdbms/admin/externaljob.ora
> > -rw-r--r--   1 root     dba           52 Sep  7 15:29
> > /h/oracle/product/10r2/rdbms/admin/externaljob.ora
> > bash sol root /h/oracle/product/10r2/bin 32 #
> > bash sol root /h/oracle/product/10r2/bin 32 # cat
> > $ORACLE_HOME/rdbms/admin/externaljob.ora
> > # externaljob.ora
> > run_user = rman
> > run_group = rman
> >
> > bash sol root /h/oracle/product/10r2/bin 33 #
> > bash sol root /h/oracle/product/10r2/bin 33 #
> >
> >
> > bash sol root /h/oracle/product/10r2/bin 33 #
> > bash sol root /h/oracle/product/10r2/bin 33 # ll $ORACLE_HOME/bin/ext*
> > -rwsr-x---   1 rman     dba        30388 Sep 21  2006
> > /h/oracle/product/10r2/bin/extjob*
> > -rwsr-x---   1 rman     dba        30392 Sep 21  2006
> > /h/oracle/product/10r2/bin/extjobo*
> > -rwsr-x---   1 rman     dba        34468 Sep 21  2006
> > /h/oracle/product/10r2/bin/extproc*
> > -rwxr-xr-x   1 oracle   dba          300 Sep 21  2006
> > /h/oracle/product/10r2/bin/extusrupgrade*
> > bash sol root /h/oracle/product/10r2/bin 34 #
> > bash sol root /h/oracle/product/10r2/bin 34 #
> > bash sol root /h/oracle/product/10r2/bin 34 #
> >
> > On my system, the user 'nobody' has no shell so I cannot use nobody.
> >
> > I created a user named rman:
> >
> >
> > bash sol root /h/oracle/product/10r2/bin 34 #
> > bash sol root /h/oracle/product/10r2/bin 34 #
> > bash sol root /h/oracle/product/10r2/bin 34 # su - rman
> > Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
> > $
> > $ id
> > uid=220(rman) gid=220(rman)
> > $
> > $
> > $ date
> > Fri Sep  7 16:30:03 PDT 2007
> > $
> > $
> >
> > Jared points out that rman needs access to extproc:
> >
> > $ ls -la /h/oracle/product/10r2/bin/extproc
> > -rwsr-x---   1 rman     dba        34468 Sep 21  2006
> > /h/oracle/product/10r2/bin/extproc
> > $
> > $
> >
> >
> > Here is a demo of rman running his script:
> >
> >
> > bash sol root /h/oracle/product/10r2/bin 35 # su - rman
> > Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
> > $
> > $
> > $ ls
> > scripts
> > $
> > $
> > $ scripts/tst.sh
> > $
> > $
> > $ cat scripts/tst.sh
> > #! /bin/sh
> > /usr/bin/date > /tmp/tst.sh.out.txt 2>&1 &
> > exit 0
> >
> > $
> > $
> > $ cat /tmp/tst.sh.out.txt
> > Fri Sep  7 16:31:23 PDT 2007
> > $
> > $ rm /tmp/tst.sh.out.txt
> > $
> >
> >
> > I am focused on this error:
> >
> > ORA-27369: job of type EXECUTABLE failed with exit code: 274662
> >
> > And I am focused on this exit code: 274662
> >
> > What does 274662 mean?
> >
> > If the Scheduler gives me an error like "274662" rather than some
> English,
> > it's obvious to me the Scheduler is a POS and I should not use it.
> >
> > And of course,
> > If I cannot run RMAN from Oracle Scheduler, I'll use cron.
> >
> > -Owen
> >
> >
> >
> > On 9/7/07, Jared Still <jkstill@xxxxxxxxx> wrote:
> > > On 9/7/07, Owen Smith <owensmith99@xxxxxxxxx> wrote:
> > > >
> > > > I'd like to run a shell script from the Scheduler in my 10g
> database.
> > > > Right now it is a simple shell script.
> > > > Eventually it will wrap RMAN commands to back up my DB.
> > > >
> > > > I wrote a simple pl/sql script to create a job:
> > > >
> > > > -- cr_job10.sql
> > > >
> > > > The scheduler, though, errors out with an error which I see in a
> trace
> > > > file:
> > > >
> > > *** 2007-09-06 17:33:00.175
> > > > ORA-12012: error on auto execute of job 53267
> > > > ORA-27369: job of type EXECUTABLE failed with exit code: 274662
> > >
> > >
> > >
> > > Running external jobs from dbms_scheduler is much like running jobs
> from
> > > cron:
> > > You must explicitly set the environment, as no environment is
> inherited.
> > >
> > > See ML Notes *387451.1 and **389685.1.*
> > >
> > >
> > > --
> > > Jared Still
> > > Certifiable Oracle DBA and Part Time Perl Evangelist
> > >
> >
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

Other related posts: