设为首页 加入收藏

TOP

我的第一个shell脚本
2017-06-20 10:22:43 】 浏览:4119
Tags:一个 shell 脚本

我的第一个shell脚本

check.sh

use aaaa;
set mapreduce.job.queuename=bbbb;

--create table zgf_check_table_pz
--(schema string,
--table_name string,
--lastmodify_time string,
--storage string,
--running_time string)
--row format delimited
--fields terminated by '|'
--stored as textfile;
--
--create table zgf_check_table_pz_tmp
--(schema string,
--table_name string,
--lastmodify_time string,
--storage string,
--running_time string)
--row format delimited
--fields terminated by '|'
--stored as textfile;

insert overwrite table zgf_check_table_pz_tmp
select  schema,table_name,lastmodify_time,storage,running_time from zgf_check_table_pz
where running_time!='${yestoday}';

--载入数据
load data local inpath './log.txt' overwrite into table zgf_check_table_pz;
--插入历史数据
insert into zgf_check_table_pz
select schema,table_name,lastmodify_time,storage,running_time
from zgf_check_table_pz_tmp;

checkcountscript.sh

#!/bin/sh

>./checksql1.sh
>./checksql2.sh
>./checksql3.sh
>./checksql1.txt
>./checksql2.txt
>./checksql3.txt

cat head.txt>checksql1.sh
cat head.txt>checksql2.sh
cat head.txt>checksql3.sh

cat ./tablename.txt | while read line
do
        id=`echo $line |awk -F '|' '{print $1}'`
        table=`echo $line |awk -F '|' '{print $3}'`
        src_table=`echo $line |awk -F '|' '{print $2}'`
        id1=$[ $id % 3]
        echo $id $id1 $table $src_table
        case $id1 in
                                                0) echo hive -e '"'use aaaa";"set mapreduce.job.queuename=bbbb";"select concat"('"$id"','|','"$src_table"','|',count(1))" from $table";"'"'">>"checksql1.txt>>checksql1.sh
                                                ;;
                                                1) echo hive -e '"'use aaaa";"set mapreduce.job.queuename=bbbb";"select concat"('"$id"','|','"$src_table"','|',count(1))" from $table";"'"'">>"checksql2.txt>>checksql2.sh
                                                ;;
                                                2) echo hive -e '"'use aaaa";"set mapreduce.job.queuename=bbbb";"select concat"('"$id"','|','"$src_table"','|',count(1))" from $table";"'"'">>"checksql3.txt>>checksql3.sh
                                                ;;
        esac
done
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇muduo读书笔记 下一篇C++面向对象

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目