I'm trying to write a shell script that will essentially query a given condition. Here's the catch. I want it to repeat the query for a duration of 3 minutes. (probably run the query, and sleep for 2 seconds)
After 1 minute, at any time IF the query returns null, the for loop will break. (the main objective is to DETECT if the query returns the results consistently for a duration of 3 minutes)
How do I incorporate the checking for the BREAK statement in the below code, after 1 minute? (does SPOOL overwrite contents of files or does it append?)
for ((i=90; i > 1 ; i--))
do
sqlplus -s username/passwd@SERVICENAME <<EOF
SET PAGESIZE 50000
SET TERM OFF
SET HEAD OFF
SET LINESIZE 200
#SET TRIMSPOOL ON
SET FEEDBACK OFF
SPOOL /appl/odd/local/bin/notification_pending.txt
select awb,rcvr_phone,rcvr_email,latest_event,latest_event_dtm,status,contact,notify_method from shipment t,notification t2 where t.id=t2.shp_id
and t2.status like 'F%'
and t2.contact not in ('Recipient not in whitelist','Invalid Email Id','Mail Service Down','Invalid Mobile Number');
SPOOL OFF
exit
/
EOF
sleep 2
done