The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Install Guide: Oracle Database 11g Release 1 on Oracle Enterprise Linux 5 iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
Integrating the Oracle Designer Legacy Table API with Oracle JDeveloper 11g ADF Busin iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
Oracle and Symantec Certify Veritas Data Center Solutions on Oracle - WebWire (press iBot UNIX and Linux RSS News 0 07-17-2007 08:30 AM
Having A Problem Connecting to Oracle Using Cron goodmis UNIX for Dummies Questions & Answers 1 03-20-2007 04:12 PM
Shell + Oracle + Cron job pathanjalireddy Shell Programming and Scripting 1 04-07-2005 02:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-22-2007
alikun alikun is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 23
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 02:10 AM..
  #2 (permalink)  
Old 03-22-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 03-22-2007
alikun alikun is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 23
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 (permalink)  
Old 04-10-2007
timarcher52 timarcher52 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 2
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 (permalink)  
Old 04-24-2007
el_guero el_guero is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 5
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0