shell脚本记录
[telepay@server-224-12 work]$ cat /data/dubbo/sh/process/dataCheck/dataCollectionCheck.sh
#!/bin/bash
if [ $# -ne 2 ]; then
echo " Usage: $0 [billingcycle] [city_Id]"
echo " billingcycle: format=YYYYMM"
echo " Demo1: $0 202002 755"
exit 1
fi
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]--||||--begin--||||||||||---$1----|||||||||||||||---check all citys---||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]begin check all citys begin"
var=`ssh bsscbs@132.121.xxxx "cd /data1/newoth_bill/tmpsend/;ls -lrt|grep ^-|wc -l"`
billingcycle=$1
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${billingcycle} total file numbers:${var}"
AMOUNT_number=0
USER_INFO_number=0
OFFER_number=0
MBI_number=0
#cat /data/dubbo/sh/process/dataCheck/code.txt | while read line ; do
exec 3< /data/dubbo/sh/process/dataCheck/code.txt
while read -u3 line
do
city=""
city_id=""
code=""
city=`echo ${line} | awk -F ',' '{print $1}'`
city_id=`echo ${line} | awk -F ',' '{print $2}'`
code=`echo ${line} | awk -F ',' '{print $3}'`
city_code=`echo ${line} | awk -F ',' '{print $4}'`
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]check ${city}"
MBI_AMOUNT_number=0
MBI_USER_INFO_number=0
MBI_OFFER_number=0
MBI_2_number=0
MBI_AMOUNT_number=`ssh bsscbs@132.121.xx "cd /data1/newoth_bill/tmpsend/;ls -lrt MBI_AMOUNT_${billingcycle}*.${code}|grep ^-|wc -l"`
MBI_USER_INFO_number=`ssh bsscbs@132.121.xx "cd /data1/newoth_bill/tmpsend/;ls -lrt MBI_USER_INFO_${billingcycle}*.${code}|grep ^-|wc -l"`
MBI_OFFER_number=`ssh bsscbs@132.121.xx "cd /data1/newoth_bill/tmpsend/;ls -lrt MBI_OFFER_${billingcycle}*.${code}|wc -l"`
MBI_2_number=`ssh bsscbs@132.121.xxx "cd /data1/newoth_bill/tmpsend/;ls -lrt MBI_${billingcycle}*.${code}|grep ^-|wc -l"`
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${city} MBI_AMOUNT_number:${MBI_AMOUNT_number};MBI_USER_INFO_number:${MBI_USER_INFO_number};MBI_OFFER_number:${MBI_OFFER_number};MBI_${billingcycle}_number:${MBI_2_number}"
if [ ${MBI_AMOUNT_number} -gt 0 ]; then
AMOUNT_number=$[$AMOUNT_number+1]
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${city} Need check cbs_userlist_report and DcMonthUserList program"
fi
if [ ${MBI_USER_INFO_number} -gt 0 ]; then
USER_INFO_number=$[$USER_INFO_number+1]
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${city} Need check DcMonthUserProdInst program"
fi
if [ ${MBI_OFFER_number} -gt 0 ]; then
OFFER_number=$[$OFFER_number+1]
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${city} Need check DcMonthUserOffer program"
fi
if [ ${MBI_2_number} -gt 0 ]; then
MBI_number=$[$MBI_number+1]
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${city} Need check acct_item,offer_inst and DcMonthUser program"
fi
if [ ${city_code} -eq ${2} ]; then
city_MBI_USER_INFO_number=${MBI_USER_INFO_number}
city_MBI_OFFER_number=${MBI_OFFER_number}
city_MBI_2_number=${MBI_2_number}
city_MBI_AMOUNT_number=${MBI_AMOUNT_number}
fi
done
exec 3<&-
if [ "${var}" -gt "7400" ] && [ "${AMOUNT_number}" -eq "21" ] && [ "${USER_INFO_number}" -eq "22" ] && [ "${OFFER_number}" -eq "22" ] && [ "${MBI_number}" -eq "22" ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_AMOUNT_number ${AMOUNT_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_USER_INFO_number ${USER_INFO_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_OFFER_number ${OFFER_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_${billingcycle} ${MBI_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total files is ${var},Number of files more than 7400"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]start chmod"
ssh bsscbs@132.121.xxxx "cd /data1/newoth_bill/tmpsend/;chmod 777 MBI*"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]chmod end"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]start mv"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.02 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.04 /data1/newoth_bill/send/"
sleep 7200
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.07 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.18 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.19 /data1/newoth_bill/send/"
sleep 7200
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.12 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.08 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.10 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.09 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.06 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.22 /data1/newoth_bill/send/"
sleep 7200
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.21 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.11 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.17 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.13 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.05 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.15 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.16 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.03 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.14 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.20 /data1/newoth_bill/send/"
ssh bsscbs@132.121.xxxx "mv /data1/newoth_bill/tmpsend/MBI*${billingcycle}*.01 /data1/newoth_bill/send/"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]mv end"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]||--END--||||||||||---$1----|||||||||||||||---check all citys---|||"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_AMOUNT_number ${AMOUNT_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_USER_INFO_number ${USER_INFO_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_OFFER_number ${OFFER_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total MBI_${billingcycle} ${MBI_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total files is ${var},Number of files less than 7400,please check"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]-||||--END--||||||||||---$1----|||||||||||||||---check all citys---|||"
fi
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]begin check ${2}"
if [ ${2} -eq "93" ]; then
if [ ${city_MBI_USER_INFO_number} -gt 0 ] || [ ${city_MBI_OFFER_number} -gt 0 ] || [ ${city_MBI_2_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_USER_INFO_number ${city_MBI_USER_INFO_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_OFFER_number ${city_MBI_OFFER_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_${billingcycle} ${city_MBI_2_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]check ${2} END!"
exit 0
else
if [ ${city_MBI_USER_INFO_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_USER_INFO_number ${city_MBI_USER_INFO_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check DcMonthUserProdInst program"
fi
if [ ${city_MBI_OFFER_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_OFFER_number ${city_MBI_OFFER_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check DcMonthUserOffer program"
fi
if [ ${city_MBI_2_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_${billingcycle} ${city_MBI_2_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check acct_item,offer_inst and DcMonthUser program"
fi
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]check ${2} END!"
exit 1
fi
else
if [ ${city_MBI_AMOUNT_number} -gt 0 ] && [ ${city_MBI_USER_INFO_number} -gt 0 ] && [ ${city_MBI_OFFER_number} -gt 0 ] && [ ${city_MBI_2_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_AMOUNT_number ${city_MBI_AMOUNT_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_USER_INFO_number ${city_MBI_USER_INFO_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_OFFER_number ${city_MBI_OFFER_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_${billingcycle} ${city_MBI_2_number}"
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]check ${2} END!"
exit 0
else
if [ ${city_MBI_AMOUNT_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_AMOUNT_number ${city_MBI_AMOUNT_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check cbs_userlist_report and DcMonthUserList program"
fi
if [ ${city_MBI_USER_INFO_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_USER_INFO_number ${city_MBI_USER_INFO_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check DcMonthUserProdInst program"
fi
if [ ${city_MBI_OFFER_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_OFFER_number ${city_MBI_OFFER_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check DcMonthUserOffer program"
fi
if [ ${city_MBI_2_number} -gt 0 ]; then
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]total $2 MBI_${billingcycle} ${city_MBI_2_number}"
else
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]${2} Need check acct_item,offer_inst and DcMonthUser program"
fi
echo "[`date +%Y-%m-%d` `date +%H:%M:%S`]check ${2} END!"
exit 1
fi
fi
浙公网安备 33010602011771号