#!/b
START=$(date +%s); datebegin=`date -d "$1" "+%Y%m%d"` dateend=`date -d "$2" "+%Y%m%d"` sdate=`date -d "$datebegin -1 days" "+%Y%m%d"` while [ "$datebegin" -le "$dateend" ] do echo $datebegin /usr/local/hivebi/bin/hive<<EOF --hive sql like: DROP TABLE IF EXISTS yourDB.yourTableName; EOF
datebegin=`date -d "$datebegin +1 day " +%Y%m%d`
sdate=`date -d "$sdate +1 day " +%Y%m%d`
done END=$(date +%s); echo $((END-START)) | awk '{print int($1/3600)":"int($1%3600/60)":"int($1%3600%60)}'
使用方法:
chmod +x test.sh ./test.sh 20160505 20160506
其中 -- 是 hive sql 中的注释符号.