handle_rov.sh 1016 B

12345678910111213141516171819202122232425262728
  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. echo "python 返回值:${python_return_code}"
  14. if [ $python_return_code -eq 0 ]; then
  15. echo "Python程序返回0,校验存在数据,退出循环。"
  16. break
  17. fi
  18. echo "Python程序返回非0值,不存在数据,等待五分钟后再次调用。"
  19. sleep 300
  20. current_hour=$(date +%H)
  21. current_minute=$(date +%M)
  22. if (( current_hour > max_hour || (current_hour == max_hour && current_minute >= max_minute) )); then
  23. echo "最长等待时间已到,失败:${current_hour}-${current_minute}"
  24. exit 1
  25. fi
  26. done