当前位置: 移动技术网 > IT编程>开发语言>C/C++ > 我的第一个shell脚本

我的第一个shell脚本

2018年10月25日  | 移动技术网IT编程  | 我要评论

a810k,检测骨龄,广西浦北天天网

我的第一个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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网