Home » RDBMS Server » Server Administration » How I run a shell script from the scheduler on 10.2.0.2.0 ?
How I run a shell script from the scheduler on 10.2.0.2.0 ? [message #265740] Fri, 07 September 2007 04:05 Go to next message
owensmith99
Messages: 11
Registered: September 2007
Location: Dallas
Junior Member
Hello Oracle People,

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

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_backup_job',
job_type => 'EXECUTABLE',
job_action => '/h/oracle/scripts/tst.sh',
start_date => '06-SEP-07 5.33.00PM US/Pacific',
repeat_interval => 'FREQ=DAILY',
end_date => '08-SEP-07 4.00.00PM US/Pacific',
enabled => TRUE,
comments => 'My Backup Job');
END;
/

I see no errors when I run the above procedure.

I checked DBA_SCHEDULER_JOBS and the job is in there.

The scheduler, though, errors out with an error which I see in a trace file:

/h/oracle/admin/orcl/bdump/orcl_j000_22396.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /h/oracle/product/10r2
System name: SunOS
Node name: sol
Release: 5.10
Version: Generic_118855-14
Machine: i86pc
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 15
Unix process pid: 22396, image: oracle@sol (J000)

*** ACTION NAME:(MY_BACKUP_JOB) 2007-09-06 17:33:00.175
*** MODULE NAME:(DBMS_SCHEDULER) 2007-09-06 17:33:00.175
*** SERVICE NAME:(SYS$USERS) 2007-09-06 17:33:00.175
*** CLIENT ID:() 2007-09-06 17:33:00.175
*** SESSION ID:(140.13520) 2007-09-06 17:33:00.175
*** 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

I googled on this:

ORA-27369: job of type EXECUTABLE failed with exit code: 274662

Google returned only 1 hit.

There, I see some evidence that I need to configure something inside
of Oracle to run shell scripts from the scheduler, but possibly just
for machines running windows. I'm running Solaris.

Do any of you know what I need to configure inside of Oracle to
run shell scripts from the scheduler?

-Owen
Re: How I run a shell script from the scheduler on 10.2.0.2.0 ? [message #265752 is a reply to message #265740] Fri, 07 September 2007 04:48 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Check here.
Re: How I run a shell script from the scheduler on 10.2.0.2.0 ? [message #265911 is a reply to message #265752] Fri, 07 September 2007 17:28 Go to previous messageGo to next message
owensmith99
Messages: 11
Registered: September 2007
Location: Dallas
Junior Member
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 is not helpful.

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
$
$


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

Re: How I run a shell script from the scheduler on 10.2.0.2.0 ? [message #265951 is a reply to message #265911] Sat, 08 September 2007 01:10 Go to previous message
owensmith99
Messages: 11
Registered: September 2007
Location: Dallas
Junior Member
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
Previous Topic: metric collection
Next Topic: ORACLE 10g installation doubt
Goto Forum:
  


Current Time: Tue Dec 06 12:07:57 CST 2016

Total time taken to generate the page: 0.09100 seconds