1.按天倒序遍历天


#!/bin/bash
firstDay=`date -d "-9 day" +%Y%m%d`
endDay=`date -d " -7 day" +%Y%m%d`
#遍历下个月的每一天
source /opt/huawei/Bigdata/hiveClient/bigdata_env
while (( $firstDay <= $endDay ))
do
beeline -e "drop table dw.dw_doc_department_$firstDay "

firstDay=`date -d "+1 day $firstDay" +%Y%m%d`

done

 

2.按小时遍历日期


#!/bin/bash
#以小时循环
#sh x.sh 2017010101 2017010301


stime=`date -d "-72 hours" +%Y%m%d%H`
etime=`date -d "-48 hours" +%Y%m%d%H`
source /opt/huawei/Bigdata/hiveClient/bigdata_env
while :
do
echo $stime
beeline -e "drop table ods.ods_order_info_dd_${stime}"
beeline -e "drop table ods.ods_user_info_dd_${stime} "
stime=$(date -d "${stime:0:8} ${stime:8:2} 1hour" +%Y%m%d%H)
if [[ $stime -gt $etime ]]
then
break
fi
done



 

相关文章:

  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2021-12-12
猜你喜欢
  • 2021-10-06
  • 2022-12-23
  • 2021-07-08
  • 2021-10-09
  • 2021-06-16
相关资源
相似解决方案