OMF管理自动添加数据文件脚本add_datafile.sh
更新:HHH   时间:2023-1-7


oracle_ray.sh这个脚本在我的博客内能找到,如需要请自行寻找

修改项:

        1 在crontab中执行不读取profile文件就找不到sqlplus。如果是linux请读取bash_profile文件

        2 egrep -v中把temp和undo2个表空间给过滤掉,以防出现错误

        

题外话:这么简单的脚本改了4个版本,我也是无奈了。其主要原因还是不细心。细心很重要,细心很重要,细心很重要。重要的事情说三遍!!!

 



#!/bin/bash
#by raysuen
#v04
. ~/.profile
AddDataFile(){
        sqlplus -s /nolog<<-RAY
                conn / as sysdba
                $1
    
        RAY
}
while true
do
        sqltring=`/export/home/oracle/scripts/ray/oracle_ray.sh type=tablespace | egrep -v "TABLESPACE_NAME|selected|new mail|UNDOTB|TEMP" |tr "%" " " | awk '{if($NF>70) print "alter tablespace "$1" add datafile '\''+data1'\'' size 128M autoextend on next 128M maxsize unlimited;"}' | egrep "^alter"`
        if [ "${sqltring:-None}" == "None" ];then
                break
        else
                AddDataFile "${sqltring}"
                #echo ${sqltring}
        fi
        
done


返回关系型数据库教程...