来源于
https://blog.csdn.net/xiaolong_4_2/article/details/80903087
#!/bin/sh
#参数传递
source /etc/profile;
source ~/.bash_profile;
BASEDIR=`dirname $0`
cd $BASEDIR
#classpath优先当前目录
CLASSPATH=$BASEDIR
#classpath其次是config目录
#classpath再次是lib目录下面的所有jar包
#设置参数
D=`date +%Y-%m-%d`
YESTODAY=`date -d "1 days ago" +%Y-%m-%d`
if [ $# == 2 ]; then
YESTODAY=$2
fi
if [ $# == 4 ]; then
D=$4
YESTODAY=$2
fi
#HQL
hive<
LOAD DATA LOCAL INPATH '$HADOOP_DATA_HOME/consume-$YESTODAY.csv' OVERWRITE INTO TABLE tlbb.consume_log PARTITION (dt='$YESTODAY');
EOF
方法二、
#!/bin/sh
Java代码 收藏代码
#参数传递
source /etc/profile;
source ~/.bash_profile;
BASEDIR=`dirname $0`
cd $BASEDIR
#classpath优先当前目录
CLASSPATH=$BASEDIR
#classpath其次是config目录
#classpath再次是lib目录下面的所有jar包
#设置参数
D=`date +%Y-%m-%d`
YESTODAY=`date -d "1 days ago" +%Y-%m-%d`
if [ $# == 2 ]; then
YESTODAY=$2
fi
if [ $# == 4 ]; then
D=$4
YESTODAY=$2
fi
echo "LOAD DATA LOCAL INPATH '/data/tlbb/hadoop_data/billlogout-$YESTODAY.csv' OVERWRITE INTO TABLE tlbb.logout_log PARTITION (dt='$YESTODAY');" | hive