counter

Hi,
I need some help.
Shell script counter. i need to add condition to check if counter is more than 10 and longer than 3 hours? it runs every 5 mins. it only check count and send email right now.
it runs in cron as below
gregcount.ksh gregdb 10 > /tmp/gregcount.out 2> /tmp/gregcount.err

if [ $# -ne 2 ]
then echo "Usage: $0 DB MAX_ALLOWED "
exit
fi
DB=$1
MAX_ALLOWED=$2
MAIL_LIST=bob
CNT=`${ORACLE_HOME}/bin/sqlplus -s \/nolog << EOF | tail +1 2>/dev/null
set pages 0
set head off
set feedback off
set termout off
set verify off
set echo off
connect system/${SYS_PWD}@${DB}
select count(*) from greg.counter;
EOF`
# echo $CNT

if [ $CNT -gt $MAX_ALLOWED ]
then mailx -s "too many ( ${CNT} ) in $1 !! " $MAIL_LIST < /dev/null
else
echo "All is well !! "
fi

Hi.

I think I understand the part of your question about the count > 10, but not at all sure about the part "longer than 3 hours".

What does that mean?

(and what does tail +2 do, and why are you directing standard error from SQL Plus when it really doesn't matter (it doesn't write there!)?)

/home/oracle/tmp10 > cat Test
sqlplus -s scott/tiger << EOF 2> /dev/null
set pages 0
set head off
set feedback off
set termout off
set verify off
set echo off
  select something from somethere_that_doesnt_exist;
EOF

/home/oracle/tmp10 > ./Test
  select something from somethere_that_doesnt_exist
                        *
ERROR at line 1:
ORA-00942: table or view does not exist