Database Reference
In-Depth Information
auto_drop => FALSE,
enabled => false);
END;
/
The job was defined as disabled, which dispels the requirement to supply a schedule. We
are now ready to run the job manually.
SQL> EXEC dbms_scheduler.run_job(job_name => 'env_job')
PL/SQL procedure successfully completed.
SQL> SELECT status, error#, additional_info
FROM dba_scheduler_job_run_details
WHERE job_name='ENV_JOB'
AND owner='SYS';
STATUS ERROR# ADDITIONAL_INFO
--------- ---------- ----------------------
SUCCEEDED 0 STANDARD_ERROR="PWD=/
SHLVL=1
_=/bin/env"
Thanks to terminating the shell script with exit code 0, the job is considered successful
(“SUCCEEDED”). The job scheduler saved the standard error output of the job in the column
ADDITIONAL_INFO of the view DBA_SCHEDULER_JOB_RUN_DETAILS . There are merely three environ-
ment variables and these are certainly not the ones you would expect. PATH , ORACLE_HOME , and
ORACLE_SID are missing. PWD —the process's working directory—is a familiar one. SHLVL and “ _
are present due to the fact that the test was performed on a Linux system, where /bin/sh is a
symbolic link to /bin/bash . SHLVL (shell level) is incremented by one each time bash starts another
instance of bash as a child process. Bash places the full path of each command it runs in the
environment variable “ _ ” (underscore), which is then inherited by child processes.
If we insist on implementing a database that can back itself up, we must run RMAN through
the scheduler in such a way that the environment variables ORACLE_HOME and ORACLE_SID are
visible. NLS_DATE_FORMAT should also be set, since it controls the date and time format used by
RMAN. Several approaches come to mind.
￿Run /usr/bin/env through the scheduler, set environment variables with the command
line arguments to env , and then have env run RMAN as in the following example:
$ /usr/bin/env ORACLE_HOME=/opt/oracle/product/db10.2 ORACLE_SID=TEN \
NLS_LANG=dd.Mon.yy-hh24:mi:ss /opt/oracle/product/db10.2/bin/rman target / \
cmdfile /opt/oracle/admin/scripts/backup.rcv msglog /opt/oracle/admin/log/rman.log
￿
Write a shell script that sets the required environment variables and then calls RMAN.
Have the scheduler run the shell script.
￿
Write a general purpose shell script wrapper that receives the name of a file with envi-
ronment variables to set as well as the program to run as input.
The third approach should be the most promising, since some reuse is possible and the
wrapper script could print the exit code of the program on standard error for later retrieval
through the view DBA_SCHEDULER_JOB_RUN_DETAILS . A sample implementation of such a wrapper
script is in the file extjob.sh in the source code depot.
 
Search WWH ::




Custom Search