统计表中有无数据并发送邮件

在ORACLE中,有时我们需要判断某个表中是否产生了数据,但是我们不能每天去查,所以可以用下面的脚本实现:如果该表产生了数据,系统自动发送邮件到邮箱

#!/bin/bash
sqlplus -s "/ as sysdba">tables.log <<eof set heading off select count(*) from dba_users; exit eof tt=$(cat tables.log|grep [0-9]) if (( $tt > 0 )) ;then echo "正常"
    sendmail else echo "异常"
fi

  

posted @ 2016-03-17 21:58  要让熊猫飞上天  阅读(180)  评论(0编辑  收藏  举报