我想写一个基本上会查询给定条件的shell脚本。这是抓住。我想让它重复查询3分钟。 (可能运行查询,并休眠2秒)编写一个shell脚本
1分钟后,如果查询返回null,任何时候for循环都会中断。 (主要目的是检测查询始终返回结果为3分钟的时间)
如何结合在下面的代码break语句检查,1分钟后? (不SPOOL覆盖文件的内容,或者它追加?)
for ((i=90; i > 1 ; i--))
do
sqlplus -s username/[email protected] <<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
为什么不在储存的程序包或程序中调用这一切? – kevinsky
看到http://stackoverflow.com/questions/27971833/in-bash-heredoc-inside-function-returns-syntax-error的一些想法。注意'dbname = $(...)'结构。祝你好运。 – shellter
@kevinsky,我不使用存储过程,因为我相信在Shell脚本,它将不能够阀芯结果到一个文件,以电子邮件通知。 – JCDrew90