history_day.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #! /bin/bash
  2. . /mnt/datadisk0/saga/bi_saga/dwh_saga/task_day/config.sh
  3. startDate=$1
  4. endDate=$2
  5. startSec=$(date -d "$startDate" "+%s")
  6. endSec=$(date -d "$endDate" "+%s")
  7. source /etc/profile.d/saga_env.sh
  8. for((i=$startSec;i<=$endSec;i+=86400))
  9. do
  10. current_day=$(date -d "@$i" "+%Y-%m-%d")
  11. start_time=$(date -d "0 day $current_day" +%Y%m%d)000000
  12. end_time=$(date -d "1 day $current_day" +%Y%m%d)000000
  13. echo current_day:"$current_day"
  14. echo start_time:"${start_time}"
  15. echo end_time:"${end_time}"
  16. echo "*******************能源数据需要减掉8小时*******************"
  17. energy_start_time=$(date -d "-1 day $current_day" +%Y%m%d)160000
  18. energy_end_time=$(date -d "-0 day $current_day" +%Y%m%d)160000
  19. echo energy_start_time:"${energy_start_time}"
  20. echo energy_end_time:"${energy_end_time}"
  21. # 执行某天的数据导入 hbase —> mysql
  22. # sh /mnt/datadisk0/saga/bi_saga/dwh_saga/task_day/py_mysql.sh energy --start_time $energy_start_time --end_time $energy_end_time
  23. # mysql -> hive
  24. # sh /mnt/datadisk0/saga/bi_saga/dwh_saga/task_day/mysql_to_hdfs.sh ods_energy_15_min $current_day
  25. # ods -> dwd
  26. # ssh hadoop01 sh /mnt/datadisk0/saga/bi_saga/dwh_saga/task_day/ods_to_dwd.sh all $current_day
  27. # 清理当天mysql中的数据
  28. # ssh hadoop01 sh /mnt/datadisk0/saga/bi_saga/dwh_saga/task_day/clean_mysql.sh clean_energy_15 $current_day
  29. # hive -> mysql
  30. # sh /mnt/datadisk0/saga/bi_saga/dwh_saga/task_day/hdfs_to_mysql.sh app_energy_day $current_day
  31. done