您的位置:首页 > 运维架构 > Shell

shell 脚本运行 hive sql

2016-05-24 18:06 387 查看
#!/b

START=$(date +%s);

datebegin=`date -d "$1" "+%Y%m%d"`
dateend=`date -d "$2" "+%Y%m%d"`
sdate=`date -d "$datebegin -1 days" "+%Y%m%d"`

while [ "$datebegin" -le "$dateend" ]
do
echo $datebegin

/usr/local/hivebi/bin/hive<<EOF

--hive sql like:
DROP TABLE IF EXISTS yourDB.yourTableName;

EOF

datebegin=`date -d "$datebegin +1 day " +%Y%m%d`

sdate=`date -d "$sdate +1 day " +%Y%m%d`

done

END=$(date +%s);
echo $((END-START)) | awk '{print int($1/3600)":"int($1%3600/60)":"int($1%3600%60)}'


使用方法:

chmod +x test.sh

./test.sh 20160505 20160506


其中 -- 是 hive sql 中的注释符号.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: