时间命令
`date -d "2020-9-10" +%s` # 将时间转化为数值用于比较
start_day=`date -d "2020-09-01 +7 day" +%Y%m%d` # 日期按步长递增并格式化
echo "now: " `date "+%Y-%m-%d %H:%M:%S"` # 打印当前时间
循环作业
#!/bin/bash
echo -e "\nbegin..."
start_day=2019-05-25 # 开始日期
end_day=2019-06-01 # 结束日期
step=7 #日期步长
while [ `date -d "$start_day" +%s` -le `date -d "$end_day" +%s` ] # 开始日期小于等于结束日期
do
dt=`date -d "$start_day" +%Y%m%d`
echo -e "\ndt=$dt"
hive -e"
set hive.execution.engine=tez;
set tez.queue.name=root.label;
-- your sql
insert overwrite table dm.dm_test_leon partition(dt=$dt)
select $dt, 1;
"
start_day=`date -d "$start_day +$step day" +%Y-%m-%d` # 调度日期按步长递增
done
echo -e "\nend with dt=$dt"
#!/bin/bash
params=$1
for param in $params
do
echo $param
done
#运行方式为:
sh tt.sh "1 2 3 4 5"
网友评论