以下是shell处理故障的一点积累,将来可能有用,先mark一下
(1)导出userid不为空,且下单日在2014-01-03日(含)以后的订单
mysql -u*** -h*** -P3307 -p**** -e "use XXX ;set names utf8; select distinct user_id, user_name from commission_order r where (r.user_id is not null and r.user_id !='' and order_date >='2014-01-03') and source='WWW'">check_user_id.txt
(2)shell脚本调用用户中心的接口比较
#!/bin/bash
count=1
cat check_user_id.txt|while read line
do
username=$(echo $line|awk '{print $NF}')
userid=$(echo $line|awk '{print $(NF-1)}')
user_id_true=$(curl http://******/api/****?username=$username|awk -F ':' '{print $1,$2,$3}'|awk -F ']' '{print $1}'|awk -F '[' '{print $NF}')
if [ $userid -ne $user_id_true ]
then
echo "username," $username ,"userid_false," $userid ,"user_id_true," $user_id_true>>check_user_id_result.txt
fi
#计数
count=$[ $count + 1 ]
echo "username," $username ,"userid_false," $userid ,"user_id_true," $user_id_true ,"count," $count
done
本文提供两个Shell脚本实例:一是导出特定条件下的订单信息;二是通过调用用户中心接口进行数据比对,并记录差异。
935

被折叠的 条评论
为什么被折叠?



