此脚本的特点为,只连接数据库一次,并不会每次要执行SQL时都连接数据库一次,所以这可以做到秒级的循环,同时如果连接异常中断还会自动重连:
#!/usr/bin/ksh
currpath=/home/oracle/scripts
while [ 1 -eq 1 ]
do
echo spool ${currpath}/refresh.spool
echo "execute p_refresh_mv()"
echo spool off
sleep 2
errcnt=`cat ${currpath}/refresh.spool|grep ORA-01012|grep -v grep |wc -l`
>${currpath}/refresh.spool
if [ "${errcnt}" -gt 0 ];then
echo connect csc/WxQcSbFbF9
else
sleep 50
fi
done | sqlplus "csc/xxxxxx"
|
阅读(2158) | 评论(0) | 转发(0) |