shell處理故障

 

以下是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 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章