date_for.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. startDate=$1
  3. endDate=$2
  4. startSec=`date -d "$startDate" "+%s"`
  5. endSec=`date -d "$endDate" "+%s"`
  6. source /etc/profile.d/saga_env.sh
  7. for((i=$startSec;i<=$endSec;i+=86400))
  8. do
  9. current_day=`date -d "@$i" "+%Y-%m-%d"`
  10. one_day_ago=`date -d "$current_day yesterday" +%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. energy_start_time=`date -d "-1 day $current_day" +%Y%m%d`160000
  14. energy_end_time=`date -d "-0 day $current_day" +%Y%m%d`160000
  15. echo current_day:$current_day
  16. echo start_time:${start_time}
  17. echo end_time:${end_time}
  18. echo "**************************************"
  19. echo energy_start_time:${energy_start_time}
  20. echo energy_end_time:${energy_end_time}
  21. /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 10101 --start_time $energy_start_time --end_time $energy_end_time
  22. sh /opt/app/bi-app/energy/dayTask/mysql_to_hdfs.sh ods_energy_15_min $current_day
  23. ssh hadoop01 sh /opt/app/bi-app/energy/dayTask/ods_to_dwd.sh all $current_day
  24. ssh hadoop01 sh /opt/app/bi-app/energy/dayTask/clean_mysql.sh clean_energy_15 $current_day
  25. sh /opt/app/bi-app/energy/dayTask/hdfs_to_mysql.sh app_energy_day $current_day
  26. done