文件导入检测及提醒

DBSTR="ccad/abc@crm"


lastday=$(perl -e "use POSIX qw(strftime); print strftime '%Y%m%d' , localtime( time()-3600*24*1) ")
curday=$(perl -e "use POSIX qw(strftime); print strftime '%Y%m%d' , localtime( time()) ")


FILES="/product1/port/bin/ocs_subscriber_import/back/GXalluserinfo_V_${lastday}_*.unl"


PHONELIST="1233344444

545435435

"


send_sms()
{
PCOUNT=0
for phone in $PHONELIST
do
TIME="EPY"`date +'%y%m%d%H%M%S'`
COMM_SN="${TIME}$1${PCOUNT}"
echo "COMM_SN=${COMM_SN}"

SQL="insert into vvv.log_sms_pay values('"$COMM_SN"','alarm','"$phone"',to_char(sysdate,'YYYYMMDDHH24MISS'),'IOC_ALARM','2',to_char(sysdate,'YYYYMMDDHH24MISS'),'"$2"',0,0,0)"
exesql "$SQL"
SQL="insert into vvv.sms_pay values('"$COMM_SN"','alarm','"$phone"',to_char(sysdate,'YYYYMMDDHH24MISS'),'IOC_ALARM','2',to_char(sysdate,'YYYYMMDDHH24MISS'),'"$2"',0,0,0)"
exesql "$SQL"

PCOUNT=`expr $PCOUNT + 1`
echo "PCOUNT=${PCOUNT}"
sleep 1
done
}




exesql()
{
sqlplus -s $DBSTR <<EOF
set autocommit off;
$1;
commit;
exit;
EOF
}




for file in $FILES
do
if [ -f "${file}" ]; then
  echo "[${file}]存在"
  fail_count=`cat ${file}|wc -l`
  echo "fail_count=${fail_count}"
tabrow=`sqlplus -S $DBSTR <<EOF1
set heading off;
set feedback off;
set pagesize 0;
set verify off;
set echo off;
select count(*)  from log_ocs_info_user where insert_date='${curday}';
exit;
EOF1`
echo "tabrow=${tabrow}"


  if [ "$tabrow" -ne "$fail_count" ]; then
  msg="ocs账本导入时文件行数与log_ocs_info_user表记录行数不匹配"
  echo $msg;
  send_sms "01" "$msg"
  fi
else
msg="ocs账本导入的文件[${file}]没有生成,请检查"
echo $msg
send_sms "02" "$msg"
fi


done


echo "结束!"


  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值