handle_rov.sh 843 B

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