写了一个检查数据库JOB HANG住时报警的脚本。

# Writen by Henry bai @20th Sep.,2008
#!/bin/sh
while true
do
hostname=`hostname`
ORACLE_SID='CNSRPT'
Last_hours=`sqlplus -s / as sysdba @check_job_status.sql`
if test $Last_hours -gt 6
then
/usr/bin/logger -p daemon.warning "cronscript: check_job_status.ksh: FAILED: $hostname: #4-$ORACLE_SID Mview_refresh failed. [MID_54878]" --added by henry
fi
sleep 6
done
-----------the check_job_status.sql----------------------
set pages 0
set head off
select (sysdate-Min(LAST_REFRESH_DATE))*24 last_hours from dba_mviews where owner<>'ECR';
exit;

你可能感兴趣的:(数据库)