handle_rov.sh 966 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. set -ex
  3. partitionDt="$(date -d '1 days ago' +%Y%m%d)"
  4. partitionHh="14"
  5. table='alg_recsys_sample_all_new'
  6. # 0 判断上游表是否生产完成,最长等待到12点
  7. source /root/anaconda3/bin/activate py37
  8. max_hour=11
  9. max_minute=00
  10. echo "开始校验是否生产完数据,分区信息:dt:${partitionDt},hh:${partitionHh}"
  11. while true; do
  12. python_return_code=$(python checkHiveDataUtil.py --table ${table} --partitionDt ${partitionDt} --partitionHh ${partitionHh})
  13. if [ $python_return_code -eq 0 ]; then
  14. echo "Python程序返回0,校验存在数据,退出循环。"
  15. break
  16. fi
  17. echo "Python程序返回非0值,不存在数据,等待五分钟后再次调用。"
  18. sleep 300
  19. current_hour=$(date +%H)
  20. current_minute=$(date +%M)
  21. if (( current_hour > max_hour || (current_hour == max_hour && current_minute >= max_minute) )); then
  22. echo "最长等待时间已到,失败:${current_hour}-${current_minute}"
  23. exit 1
  24. fi
  25. done