Operating System - HP-UX
1753265 Members
5445 Online
108792 Solutions
New Discussion юеВ

batch command and oracle jobs

 
SOLVED
Go to solution
Eileen Millen
Trusted Contributor

batch command and oracle jobs

Does anyone use the batch command with Oracle jobs? Our Financial folks would like some sort of a queue system. Any suggestions
3 REPLIES 3
Alexander M. Ermes
Honored Contributor

Re: batch command and oracle jobs

Hi Eileen.
We have a lot of jobs running in background.
We use to start these jobs from the cron as root with a shell script. For sample doing a report we use report.sh and within this script we use lines like su - orace -c .......
One problem : if you run these jobs you may show usernames and passwords. Try to hide them in parameter files.
Hope i could help you.
Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Jim Wolff
Occasional Advisor

Re: batch command and oracle jobs

Hi Eileen,

As Alexander mentioned, you can run batch processes as a cron job (and of course you may want to hide the password from appearing in the process list or hardcoding it in your scripts).

One thing you will want to do if you are planning to run processes using a SQL-Plus session is to use the "-s" option until end-of-file as shown in my example below.

===============================
#!/bin/ksh
#
# example SQL-Plus script for batch processing

PSWD=`cat /ora0/oracle/passwd/sys`;
SIDFILE='/ora0/oracle/scripts/all_sids'
ORACLE_HOME='/ora0/oracle/app/oracle/product/8.1.6'
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:
export PATH


cat $SIDFILE | while read SID
do
ORACLE_SID=$SID
export ORACLE_SID
sqlplus -s sys/$PSWD@$SID <
set linesize 120

@/ora0/oracle/scripts/user_info.sql
@/ora0/oracle/scripts/tblsp_info.sql
@/ora0/oracle/scripts/high_water.sql
!/ora0/oracle/scripts/archive_stats

EOF

done

#========= end of script ==========

In the above example, I am reading the name of the database from a file called "all_sids" which allows me to run a loop and process the same scripts for all databases listed in the file..

Next, in order to avoid hardcoding the password in the script, I am reading the password from a file on the operating system that I have set to read only by Oracle.

Finally, when I run the sqlplus command, I am feeding in the variables for the password and oracle_sid explained above, then simply executing my scripts as in a normal sqlplus session.

Last, I am running an OS command to archive my output files generated from the sql scripts.

Hope this helps.

Best regards,

jim wolff
Sr. Oracle DBA
Dieter Degrendele_1
Frequent Advisor
Solution

Re: batch command and oracle jobs

Hi,

Also we have some hundreds of batch jobs for our Oracle environments. Because there are so much jobs we decided to use the Enterprise Management module from Computer Associates (www.ca.com).

Probably this would help you a bit:

create a unix script that calls some SQL or PL/SQL scripts. Test it and put it in the crontab. Use man crontab for information about use. Sometimes it is great to use the logger command into your unix scripts. Then you can create another script that does a tail -f of /var/adm/syslog/syslog.log and mails all your messages to your email address. Anyhow, this is what we do and it seems to be working for a long time.

Regards,

Dieter Degrendele
The possible we did, the unpossible we're doing but for a miracle you have to wait some time.