crontab+shell 作业流程调度

在前面的文章中,我们有简单提到过 shell or python 调度hive 的 伪代码 ,今天我们在丰富下 这些伪代码

http://blog.csdn.net/haohaixingyun/article/details/51821444

说明,在实际生产环境中,可能会部署一些成熟的作业流程调度引擎 Oozie  or  Azkaban 等 ,更多详细资料 请自行查阅

今天我们有三段shell 脚本为代码 ,代码有参考网上教学资料


1. crontab

*/10 * * * * root /opt/main.sh

2,mapreduce_job.sh 脚本

cmd = "hadoop jar example.jar xxx-D......."

$cmd

code=$?

while[$code !=0];do

echo "run job failed ,run submit ......"

$cmd

done

3,hive_job.sh 脚本

cmd =“”hive -e \" use mydatabase ;alter table t add if not exists partition (pt = "20160719") location '/gr/data/20160719;

          select count(*) from t where pt = '20160719'\'' ''

$cmd

code=$?

while [$code!=0];do

echo "run job failed ,run submit ......"

$cmd

done

4, main.sh  建立依赖关系

sh mapreduce_job.sh

sh hive_job.sh



posted @ 2016-07-19 23:16  yuerspring  阅读(283)  评论(0编辑  收藏  举报