本文共 3453 字,大约阅读时间需要 11 分钟。
#!/bin/bash. /home/enterprisedb/.bash_profileEMAIL="noc@xxx.com dba@xxx.com"# check running marktest -f /home/enterprisedb/script/run/tbl_charge_xxxx.runif [ $? -eq 0 ]; thenSYNC_TIME_CHECK="'`ls -1 -l --time-style=+%F\ %T /home/enterprisedb/script/run/tbl_charge_xxxx.run|awk '{print $6" "$7}'`'" psql -t -h /tmp -p 1921 -U enterprisedb -d edb </home/enterprisedb/script/tbl_charge_xxxx.timeoutstats 2>&1select 'sync_time_out' where now()-$SYNC_TIME_CHECK::timestamp without time zone>interval '1 hour';EOFTIME_OUT_ERROR=0TIME_OUT_ERROR=`grep -c "sync_time_out" /home/enterprisedb/script/tbl_charge_xxxx.timeoutstats`if [ $TIME_OUT_ERROR -ne 0 ]; thenecho -e "`cat /home/enterprisedb/script/tbl_charge_xxxx.timeoutstats`\n\n`date +%F%T`\n sync xxxx xltj.msss.sa_sales_info_xxxx timeout!\n\nPlease Call Digoal!\n"|mutt -s "Sync xxxx XLTJ timeout!" $EMAILecho -e "sync timeout"fiexit 3fi# create running marktouch /home/enterprisedb/script/run/tbl_charge_xxxx.runMAX_T="'`psql -t -h /tmp -p 1921 -U enterprisedb -d edb -c "select max(id) from msss.tbl_charge_xxxx_recent@edb.xl_local"|sed -e 's/ //g'`'"echo $MAX_Tpsql -t -h /tmp -p 1921 -U enterprisedb -d edb < /home/enterprisedb/script/tbl_charge_xxxx.stats 2>&1begin;select 'start sync: '||now();delete from msss.tbl_charge_xxxx_recent@edb.xl_local where id < $MAX_T ;insert into msss.tbl_charge_xxxx_recent@edb.xl_local (id,mobile,xxxxxx,xxxx,mobi_factory,mobi_mode,hsv,org_id,ver,send_date,create_date,MODEVER,BUILDTIME) select id,trim(coalesce(phonenum,'nvl')),trim(xxxxxx),trim(xxxx),trim(coalesce(hsman,'nvl')),trim(coalesce(hstype,'nvl')),to_number(hsversion,'99999999999999999999'),trim(hsman),to_number(appversion,'99999999999999999999'),to_char(motime,'yyyymmddhh24miss'),to_char(createtime,'yyyymmddhh24miss'),trim(coalesce(SOFTVERSION,'nvl')),trim(coalesce(SOFTCOMPILETIME,'nvl'))from xxxx.tbl_charge_xxxx@edb.xxxx_pg whereid > ${MAX_T}and appid=810007;insert into msss.SA_SALES_INFO_xxxx@edb.xl_local (id,mobile,xxxxxx,xxxx,mobi_factory,mobi_mode,hsv,org_id,ver,mccid,MODEVER,BUILDTIME)selectid,coalesce(mobile,'nvl'),xxxxxx,xxxx,coalesce(mobi_factory,'nvl'),coalesce(mobi_mode,'nvl'),hsv,org_id,ver,case substring(xxxx,1,3) when ('234','235') then '234' when ('310','311','312','313','314','315','316') then '310' when ('430','431') then '430' when ('440','441') then '440' when ('460','461') then '460' else substring(xxxx,1,3) end,MODEVER,BUILDTIMEfrom msss.tbl_charge_xxxx_recent@edb.xl_localwhere id > ${MAX_T} ;commit;EOF# loggingcat /home/enterprisedb/script/tbl_charge_xxxx.stats >> /home/enterprisedb/script/tbl_charge_xxxx.log# delete running marksleep 10rm -f /home/enterprisedb/script/run/tbl_charge_xxxx.runERROR=0ERROR=`grep -c "ROLLBACK" /home/enterprisedb/script/tbl_charge_xxxx.stats`if [ $ERROR -ne 0 ]; thenecho -e "`cat /home/enterprisedb/script/tbl_charge_xxxx.stats`\n\n`date +%F%T`\n sync xxxx xltj error!\n\nPlease Call Digoal!\n"|mutt -s "Sync xxxx XLTJ error!" $EMAILecho -e "sync error"fi
转载地址:http://oehca.baihongyu.com/