spooltable.sh
#!/bin/bash
export ORACLE_SID=rac1
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=/home/oracle/9.2.0
export ORA_NLS33=/home/oracle/9.2.0/ocommon/nls/admin/data
PATH=$PATH:$ORACLE_HOME/bin; export PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/$ORACLE_HOME/lib; export LD_LIBRARY_PATH
ORACLE_OWNER=oracle; export ORACLE_OWNER
ORACLE_NLS=$ORACLE_HOME/ocommon/nls/admin/data ; export ORACLE_NLS
NLS_LANG="simplified chinese"_china.ZHS16CGB231280 ; export NLS_LANG
EDITOR=vi;export EDITOR
cd /home/oracle/cron
sqlplus -s user/pwd @excel.sql >tablespool_`date +%Y%M%D`.csv
excel.sql
set head off time off timing off feedback off echo off pagesize 0
select product_id||','||last_upd_dtm from art_log;
exit
The cronjob to do this:
crontab -l:
0 0 * * * /home/oracle/cron/spooltable.sh
阅读(1441) | 评论(0) | 转发(0) |