#!/bin/bash
##要求传入的数据格式为yyyyMMdd的两个开始和结束参数，如20190901
start=$1
##结束时间为当前时间20190919
end=$(date "+%Y%m%d")
##将输入的日期转为的时间戳格式
startDate=`date -d "${start}" +%s`
endDate=`date -d "${end}" +%s`
##计算两个时间戳的差值除于每天86400s即为天数差
stampDiff=`expr $endDate - $startDate`
daySub=`expr $stampDiff / 86400`
echo "间隔天数："$daySub
sh ./his-day.sh $1 $daySub
sh ./his-week.sh $1 $daySub
##计算间隔的月数，先计算间隔年数
yearSub=`expr ${end:0:4} - ${start:0:4}`
monthSub=`expr ${end:4:2} - ${start:4:2}`
monthSub=`expr ${yearSub} \* 12 + ${monthSub}`
echo "间隔月数："${monthSub}
sh ./his-month.sh $1 $monthSub
echo "间隔年数："$yearSub
sh ./his-year.sh $1 $yearSub
sh start-azkaban-statistics-farm.sh Stat