Search This Blog

Tuesday, December 20, 2011

run sql commands in background (similar to nohup in os)

vi test.sql
--------------
spool test.log
select name from v$database;
select name from v$database;
select name from v$database;
spool off;
exit

vi script.sh
-----------------
#! /bin/ksh
export ORACLE_SID=dbname
export ORACLE_HOME=/ora01/app/oracle/product/10.2.0
export PATH=$ORACLE_HOME/bin:$PATH
cd /ora01
sqlplus / as sysdba @test.sql
exit 0

$ chmod 777 test.sql script.sh

crontab -e
-----------------
41 15 15 06 * /ora01/script.sh mail myemail@gmail.com

No comments:

Post a Comment