Skip to content

Instantly share code, notes, and snippets.

@ningyuwhut
Created September 5, 2018 03:09
Show Gist options
  • Save ningyuwhut/720992023c7075665285c842775a36a8 to your computer and use it in GitHub Desktop.
Save ningyuwhut/720992023c7075665285c842775a36a8 to your computer and use it in GitHub Desktop.
run a shell job multiple days
sdate=$1 #`date -d'-1 days' +"%Y%m%d"`
edate=$2 #`date -d'+0 days' +"%Y%m%d"`
date=$sdate
declare -a date_array=()
#先生成日期数组,然后依次遍历数组中的日期
while [ $date -ne $edate ];do
echo "date", $date
date_array=("${date_array[@]}" $date)
date=`date -d"$date 1 day" '+%Y%m%d'`
done
#打印数组长度,即天数
echo ${#date_array[@]}
echo "print date_array"
for date in ${date_array[@]}; do
echo $date
done
for date in ${date_array[@]}; do
echo $date
sh run_real_time.sh $date
if [ $? -ne 0 ];then
echo "task of $date failed"
exit -1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment