#!/bin/bash
first="$1"
second="$2"
date_ymd="$3"
while [ "$first" != "$second" ]
do
echo "$first"
date_ymd="$first"
echo "$date_ymd"
./mysql2hivebysqoop2.sh $first
first=`date -d "$date_ymd yesterday" "+%Y-%m-%d"`
echo "$first"
done
其中MySQL2hivebysqoop2.sh
#!/bin/bash
ymd="$1"
echo "$ymd"
sqoop import --connect jdbc:mysql://########## --username root --password ######### --query 'select * from dms_collection_vod_play where create_date="'$ymd'" and $CONDITIONS' --target-dir /user/Larkin/sqoop/dms_collection_vod_play/date_ymd="$ymd" --delete-target-dir --num-mappers 1 --compress --compression-codec org.apache.hadoop.io.compress.SnappyCodec --hive-import --hive-overwrite --hive-database testonly --hive-table dms_collection_vod_play --hive-partition-key date_ymd --hive-partition-value $1 --fields-terminated-by '\t'