#!/bin/bash
stime=$1
etime=$2
#不支持任意时间段 ./totalProcess_his_v2_hor.sh "2021-01-01 00:00:00" "2021-02-01 00:00:00"
while [[ $(date -d "${stime}" +%s) -le $(date -d "${etime}" +%s) ]]; do
#插值入库开始时间
start=$(date -d "${stime} 8 hours ago" "+%Y-%m-%d %H:%M:%S")
next_time=$(date -d "${stime} 1 month" "+%Y-%m-%d %H:%M:%S")
#插值入库结束时间
end=$(date -d "${next_time} 8 hours ago" "+%Y-%m-%d %H:%M:%S")
s1=$(date -d "${start}" "+%Y%m%d%H%M%S")
s2=$(date -d "${end} 1 second ago" "+%Y%m%d%H%M%S")
echo ${s1}
echo ${s2}
# 开始执行插值、解析、入库
echo "sh /home/cy/parse_his/V2_HIS_ALL_HOR.sh ${s1},${s2}"
sh /home/cy/parse_his/V2_HIS_ALL_HOR.sh ${s1},${s2}
wait
echo "下一次时间 ${next_time}"
while [[ $(date -d "${stime}" +%s) -le $(date -d "${next_time}" +%s) ]]; do
#评估时间
pg_time=$(date -d "${stime} 1 hours" "+%Y-%m-%d %H:%M:%S")
echo "sh /home/cy/ass/twohis-hour.sh ${pg_time}"
cd /home/cy/ass/ && sh /home/cy/ass/twohis-hour.sh ${pg_time} $3
wait
echo "小时评估结束:时间为:${pg_time}"
ymd=$(date -d "$pg_time" +"%d")
hm=$(date -d "$pg_time" +"%H:%M")
echo ${ymd} ${hm}
if [[ ${hm} = "00:00" ]]; then
echo "日评估 sh /home/cy/ass/twohis-day.sh ${pg_time} $4"
cd /home/cy/ass/ && sh /home/cy/ass/twohis-day.sh ${pg_time} $4
wait
if [[ ${ymd} = "01" ]]; then
echo "月评估 sh /home/cy/ass/twohis-month.sh ${pg_time} $5"
cd /home/cy/ass/ && sh /home/cy/ass/twohis-month.sh ${pg_time} $5
wait
fi
fi
# 将开始时间设置为下一个小时的开始时间
stime=${pg_time}
if [[ $(date -d "${stime}" +%s) -ge $(date -d "${etime}" +%s) ]]; then
break
fi
done
echo "cd /home/cy/clearData/ && sh /home/cy/clearData/twoNow.sh ${s1},${s2}"
#cd /home/cy/clearData/ && sh /home/cy/clearData/twoNow.sh ${s1},${s2}
# 将开始时间设置为下一个月的开始时间
stime=${next_time}
if [[ $(date -d "${stime}" +%s) -ge $(date -d "${etime}" +%s) ]]; then
break
fi
done
跑历史脚本按月,传入开始时间,结束时间
最新推荐文章于 2024-07-31 19:51:17 发布