Unix/Linux Go Back    


UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

Execute Oracle pl/sql commands in a scrit using nohup

UNIX and Linux Applications


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-08-2017   -   Original Discussion by alexcol
alexcol's Unix or Linux Image
alexcol alexcol is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 20 February 2018, 11:06 AM EST
Location: Bogota - Colombia - South America
Posts: 100
Thanks: 3
Thanked 1 Time in 1 Post
Execute Oracle pl/sql commands in a scrit using nohup

Good afternoon:
I need your help please, Im new at Unix nd specially Unix applicationas like oracle and Ive got this problem:

I was asked to execute the next script using nohup in order to not hang up the session because it was supposed to connect to the database and then insert about 2 millions of rows to a table
and this process akes about 2 hours

I run this script with oracle user because of privilige issues previusly exporting some oracle vars



Code:
export ORACLE_SID=XYZ
export TWO_TASK=XYZ

SCEL:/oracle/oracle/PACKAGES/CXYZ/Install oracle@prosclbt00c # id
uid=1000(oracle) gid=26(dba)

nohup ./install_bd.ksh &

But after 12 hours or more this process continue writing both logs consuming so much space



Code:
-rw-------   1 oracle   dba         1.8G Dec  8 12:23 nohup.out
-rw-r-----   1 oracle   dba         1.8G Dec  8 12:23 install_1_0_SCEL.log

Sadly, we validate with our DBA if there was any session but he said there was neither session with OSUSER oracle nor any other sessions affecting the specified tables.

So it was likely the process was redirecting the output to both logs but it never connected to the DATABASE, dont know for sure:

This is the scriptinstall_bd.ksh

This is the scriptinstall_bd.ksh



Code:
 more install_bd.ksh
#!/bin/ksh
# Descripcion: ASB
# Cambio de:
#       


time sqlplus /<<EOF
set echo on verify on feedback 1 timing on time on pages 10000 lines 132 trimspool on tab off flush off
/
WHENEVER SQLERROR CONTINUE
set echo on verify on feedback 1 timing on time on pages 10000 lines 132 trimspool on tab off flush off

spool install_1_0$1_$ORACLE_SID.log

@install_1_0.sql

spool off
disconnect
EOF

resultado=$(egrep "ORA-|PLS-|SP2-" sclsql_$1_$ORACLE_SID.log |grep -v "ORA-00001" | grep -v "ORA-01430" |grep -v "ORA-01921" | grep -v "ORA-01920" |sort -u > final.log)

hay_error=`wc -l final.log | awk '{ print $1 }'` 

ls -ltr *.log
cat final.log
rm final.log
echo "ERRORES ENCONTRADOS "$hay_error
exit

The questions are:

1. I would like to know it was something wrong executing the scrpit install_bd.ksh & using nohup?

2 if so how to control the proceses can not hang up? wouldnt it better to modify inside the script install_bd.ksh this line:



Code:
nohup time sqlplus /<<EOF ?

I'd appreciate your help in advanced
Sponsored Links
    #2  
Old Unix and Linux 12-08-2017   -   Original Discussion by alexcol
jim mcnamara's Unix or Linux Image
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 23 February 2018, 7:38 PM EST
Location: NM
Posts: 11,307
Thanks: 587
Thanked 1,136 Times in 1,046 Posts
You have made the process hard to debug and to maintain.

First off spool files have limitations as to number of lines, for example.
Are you really expecting 10000 lines of output? I would consider using something like at
to run, logon as user oracle, then:
[code]


Code:
at -m now <<!
sqlplus /
set echo on verify on feedback 1 timing on time on pages 10000 lines 132 trimspool on tab off flush off
/
WHENEVER SQLERROR CONTINUE
set echo on verify on feedback 1 timing on time on pages 10000 lines 132 trimspool on tab off flush off
@install_1_0.sql
disconnect
!

Why? possibly because you have an error condition that generates tons of garbage.

But oracle user gets notified when the job ends - email - and you do not create a gigantic file except in /var/mail (or wherever mail text is stored in your system).
You may also want to edit the .sql file to remove a lot of chatty output. Otherwise your problems are lost in a sea of junk notifications.

BTW: if you are getting all of those ORA notifications (the ones you grep -v) your script or your data need to be looked at carefully. A script should throw one fatal error then abort not keep on running. Otherwise you run the risk of corrupting indexes, creating orphans and so on. Example ORA-01921 deals with junk/bogus roles in a connect string. That should never happen. Why would a process need to keep connecting to new db's if it is designed correctly? Aside from that fact, it is a huge overhead.

Last edited by jim mcnamara; 12-08-2017 at 10:45 PM..
Sponsored Links
    #3  
Old Unix and Linux 12-09-2017   -   Original Discussion by alexcol
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 24 February 2018, 4:34 AM EST
Location: Aachen, Germany
Posts: 12,169
Thanks: 371
Thanked 3,752 Times in 3,447 Posts
Run your script interactively with a small subset of a) correct b) erroneous data to see what happens.
    #4  
Old Unix and Linux 12-09-2017   -   Original Discussion by alexcol
alexcol's Unix or Linux Image
alexcol alexcol is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 20 February 2018, 11:06 AM EST
Location: Bogota - Colombia - South America
Posts: 100
Thanks: 3
Thanked 1 Time in 1 Post
ok thank you very much for your support. i will keep in mind your suggesttions
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Execute multiple SQL scripts from single SQL Plus connection guif Shell Programming and Scripting 6 10-25-2010 12:31 PM
Execute PL/SQL function from Unix script (.sql file) reptile UNIX for Dummies Questions & Answers 1 05-14-2009 08:40 AM
using mutiple "nohup" to execute multiple commands. aster007 Shell Programming and Scripting 2 03-06-2009 12:35 PM
how can i install sqlplus and execute some sql commands talipk AIX 2 12-02-2008 04:54 AM



All times are GMT -4. The time now is 06:13 AM.