using Oracle with Cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using Oracle with Cron
# 1  
Old 03-22-2007
using Oracle with Cron

Greetings,

I am doing some work on using Oracle with Cron and was wondering if you could help. I am relatively new both to Oracle and Unix. Please be patient :-)

Here is what I am trying to do:

I wish to know the contents of employees table in scott account everyday at 11 am, save a copy at my directory /home/alikun and send another to a user at email address removed by moderator

This is what I did but couldn't get results:

1. Created a vi script, scottcron.sql, containing the query:

spool /home/alikun
select * from employees;
exit;

2. wrote a separate script, scottshell, to execute the script above:

/home/alikun/Sqlplus scott/tiger @/home/alikun/scottrcron.sql

3. Finally, the cron script, mycron, as follows:

00 11 * * * “/home/alikun/scottshel” | mail -s “hi zalikun, this is your file” email address removed by moderator

crontab mycron

Please note: I did a bit of research on this and it seems that I would need two other things:

a) ORACLE_HOME=
b) B) ORACLE_SID=

How can I find the path for ORACLE_HOME in a), and the SID for b) on my unix system?.

Thanks all so very much,
Alikun

Last edited by blowtorch; 03-22-2007 at 03:10 AM..
# 2  
Old 03-22-2007
Hi, I don't know if the email address posted was a real one or not, but I have removed it anyway.

Now I am no DBA, but I think that you should be aware of the SID before you can run any SQL commands/scripts in any Oracle database. Once you know the SID, you can get ORACLE_HOME from the oratab file on your system. The location of the oratab file can change depending on the OS and the installtion. On HP systems, usually present in /etc and on Sun, in /var/opt/oracle. This may ofcourse differ.

If you want to run the script for every oracle instance that is running, just do a 'ps -ef | grep pmon | grep -v grep' to get the list of instances and proceed to run the script on those.
# 3  
Old 03-22-2007
Blowtorch, thanks a lot for input; indeed oratab turned out to be under /etc. Yes, i knew the oracle sid was enterprise edition; was, however, unsure of how to reference it - seems to be EE.

No, the email address was not a real one, but do appreciate your sensitivity to privacy issues ;-)
# 4  
Old 04-10-2007
Hello, I have a small example on how I call SQLPlus and PL/SQL procedures through cron. My example is located at:
<a href="http://timarcher.com/?q=node/48">http://timarcher.com/?q=node/48</a>

Hopefully it helps you!
# 5  
Old 04-24-2007
Alikun

You also need to set spool off
$ sql> spool off

$ cat scottcron.sql
spool /home/alikun
select * from employees;
spool off
exit;


Quote:
Originally Posted by alikun
Greetings,

I am doing some work on using Oracle with Cron and was wondering if you could help. I am relatively new both to Oracle and Unix. Please be patient :-)

Here is what I am trying to do:

I wish to know the contents of employees table in scott account everyday at 11 am, save a copy at my directory /home/alikun and send another to a user at email address removed by moderator

This is what I did but couldn't get results:

1. Created a vi script, scottcron.sql, containing the query:

spool /home/alikun
select * from employees;
exit;

2. wrote a separate script, scottshell, to execute the script above:

/home/alikun/Sqlplus scott/tiger @/home/alikun/scottrcron.sql

3. Finally, the cron script, mycron, as follows:

00 11 * * * “/home/alikun/scottshel” | mail -s “hi zalikun, this is your file” email address removed by moderator

crontab mycron

Please note: I did a bit of research on this and it seems that I would need two other things:

a) ORACLE_HOME=
b) B) ORACLE_SID=

How can I find the path for ORACLE_HOME in a), and the SID for b) on my unix system?.

Thanks all so very much,
Alikun
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

3. UNIX for Advanced & Expert Users

How to i execute .rdf file oracle report automatically in cron tab unix

Hi, I want to execute .rdf file which uses oracle report in crontab ..Can you please help me out how to schedule it crontab.as it is a rdf file Please give any suggestions regarding the above issue. (0 Replies)
Discussion started by: soumyamishra
0 Replies

4. Solaris

oracle cron script failing.

I have this oracle script which my dba is trying to run as a cron job that fails. attached is the script. It seems to run when executed by itself but just not when scheduled. (3 Replies)
Discussion started by: Kjons76
3 Replies

5. UNIX for Dummies Questions & Answers

Oracle Apps Cron Job

Hi, I have created a shell script which will ftp a file from my Oracle DB server to a remote server - I've named this ftp_test.sh. I have set up a cron job to fire off the shell script and when I set the job I get a message returned that the job has been installed and everything seems o.k.... (1 Reply)
Discussion started by: cjhall01
1 Replies

6. AIX

AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log

Hi, I can use 'crontabs –e' and do all the scheduling I like. However I would like to auto send myself just the cronjobs logs that fail. That is to say the PIDs that fail and the related lines with those PID’s only. (Not the full set of logs) Has anyone done this work? Or does an AIX 5.3 tool... (0 Replies)
Discussion started by: Keith Johnson
0 Replies

7. UNIX for Dummies Questions & Answers

Having A Problem Connecting to Oracle Using Cron

Can someone tell me how to prevent this? stty: standard input: Invalid argument ERROR: ORA-12154: TNS:could not resolve the connect identifier specified SP2-0306: Invalid option. Usage: CONN where <logon> ::= <username> | / ERROR: ORA-12162: TNS:net service name is incorrectly... (1 Reply)
Discussion started by: goodmis
1 Replies
Login or Register to Ask a Question