月循环
if [ $# -eq 0 ];then
day=`date --date='1 days ago' +%Y%m%d`
enddate=`date --date='1 days ago' +%Y%m%d`
elif [ $# -eq 2 ];then
enddate=$1
day=$2
else
echo "Sir,the Param num is wrong??only accept 0 or 2 input parameter"
exit 255
fiwhile [[ $day -ge $enddate ]]
do
d_day=`date -d "0 day $day" +%d`if [ $d_day -eq 01 ];thenday2=`date -d "-1 day $day" +%Y%m%d`
day1=`date -d "-1 day $day" +"%Y%m"01`echo "day1:" ${day1}
echo "day2:" ${day2}spark-sql --master yarn --deploy-mode client --conf spark.shuffle.service.enabled=true --conf spark.dynamicAllocation.enabled=true -f /else
echo "exit shell"
fiday=`date -d "-1 day $day" +%Y%m%d`
done
日循环
#!/bin/bash#owner:bidw
#cronTime: 0 5 * * *
#author:
#mail:
#commitDate: 2016-08-03
#inputData:def.d_user 量级:100 million
#outputData:dml.user_center_fund,量级:1w
#private:
#cronDir:/auto_cron/cron-running/bidw/dml/user_center
#cronfile:bidw-sh-dml-user_center_fund.sh
#cronlogDir:
#describe:计算用户中心用户基金部分信息
#note:
# 思路简述:
#
#
# version history:
# 1.0 20160803 samuel createif [ $# -eq 0 ];then
day=`date --date='1 days ago' +%Y%m%d`
enddate=`date --date='1 days ago' +%Y%m%d`
elif [ $# -eq 2 ];then
enddate=$1
day=$2
else
echo "Sir,the Param num is wrong??only accept 0 or 2 input parameter"
exit 255
fi
source /etc/profile
#依赖脚本,空格间隔
#shells="bidw-sh-ods-app_event_log.sh_flag bidw-sh-ods-app_start_log.sh_flag"
# curFileFullName=${BASH_SOURCE[0]}; curFileName_withExt=${curFileFullName##*/}; curFileName=${curFileName_withExt%%.*}; #当前文件名称
# CheckShellBaseDir=/auto_cron/cron-running/common/ #依赖检查模块路径
# curr_dir=$(cd "$(dirname "$0")"; pwd)
# sh ${CheckShellBaseDir}check_before.sh ${day} ${curFileName_withExt} ${curr_dir} ${shells}while [[ $day -ge $enddate ]]
do
spark-sql --master yarn --deploy-mode client --conf spark.shuffle.service.enabled=true --conf spark.dynamicAllocation.enabled=true -f /auto_cron/cron-running/dsql -d day="${day}"#hiveF /auto_cron/cron-running/dam/app_stats/bidw-sql-dml-app_stats.sql -day ${day}day=`date -d "-1 day $day" +%Y%m%d`
done