码迷,mamicode.com
首页 > 数据库 > 详细

REDHAT LINUX_ORACLE11G自动每天发生ADDMRPT报表

时间:2014-08-15 19:40:19      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:blog   http   os   io   文件   ar   cti   linux   

#!/bin/bash
# creator:  shark
# function: get addm report
# http://blog.csdn.net/zengmuansha


date
#设置环境变量
export ORACLE_SID=shark1
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export NLS_LANG=american_america.zhs16gbk

#设置运行是变量
SQLPLUS=$ORACLE_HOME/bin/sqlplus
LOGFILE=/home/oracle/dbscripts/logs/addmreport.txt     #日志文件
REPFILE=/home/oracle/dbscripts/logs/addmreporxt.txt     #报表文件

#获得昨天开始和结束的2个快照点
$SQLPLUS -S shark/3838<<EOF
set echo off
set feedback off
set heading off
set pagesize 0
set linesize 1000
set trimspool on
set timing off
spool $LOGFILE

select snap_id
  from dba_hist_snapshot
 where instance_number=1
  and begin_interval_time >= trunc(sysdate-1)
  and end_interval_time < trunc(sysdate)
 order by end_interval_time asc;


spool off;
set echo on
set feedback on
set heading on
exit
EOF

line1=`head -n 1 $LOGFILE`

line2=`tail -n 1 $LOGFILE`

echo "line1 is"$line1

echo "line2 is"$line2

set echo off
set feedback off

#产生报表
rm $REPFILE
$SQLPLUS -S shark/235619 <<EOF
define begin_snap=$line1
define end_snap=$line2
define report_name=$REPFILE
@?/rdbms/admin/addmrpt
exit
EOF

#发送邮件
 mail  -s `date +%Y%m%d%H`‘-‘`hostname`_addmreport dba01@lotery.hk < $REPFILE

REDHAT LINUX_ORACLE11G自动每天发生ADDMRPT报表,布布扣,bubuko.com

REDHAT LINUX_ORACLE11G自动每天发生ADDMRPT报表

标签:blog   http   os   io   文件   ar   cti   linux   

原文地址:http://blog.csdn.net/zengmuansha/article/details/38589183

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!