开发者社区 问答 正文

hadoop中使用crontab调度检查循环等待前置任务结束的返回源代码和相关意义是什么?

hadoop中使用crontab调度检查循环等待前置任务结束的返回源代码和相关意义是什么?

展开
收起
游客yzrzs5mf6j7yy 2021-12-06 08:11:06 493 分享 版权
1 条回答
写回答
取消 提交回答
  • 当前置任务还没有结束时,需要循环等待。有两种方法,一种是自己在Bash脚本里写代码,如下:
    
    
      hadoop_check_file_exist "$hbase_dir/$table_name/pt=-$bizdate"
      while [ $? -ne 0 ] 
      do  
        local hh=`date '+%H'`
        if [ $hh -gt 23 ]
        then
            echo "timeout, partition still not exist"
            exit 1
        fi  
        log_info "$hbase_dir/$table_name/pt=-$bizdate doesn't exist, wait for a while"
        sleep 5m
        hadoop_check_file_exist "$hbase_dir/$table_name/pt=-$bizdate"
      done 
    
    
    
    2021-12-06 08:11:23
    赞同 展开评论