码迷,mamicode.com
首页 > 系统相关 > 详细

脚本shell每小时递增运行task

时间:2016-09-26 16:07:12      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

下面 hello 是开始时间, world 是结束时间

 

#!/bin/bash

START=$(date +%s);

hello="20160911 00"
world="20160911 03"

datebegin=`date -d "$hello" "+%Y%m%d%H"`
dateend=`date -d "$world" "+%Y%m%d%H"`

while [ "$datebegin" -le "$dateend" ]
do
echo $datebegin

echo $datebegin >> test.txt

middle=" "
before=`echo $datebegin | cut -c 1-8`
after=`echo $datebegin | cut -c 9-10`
tmp="$before$middle$after"

datebegin=`date -d "$tmp +1 hour " +%Y%m%d%H`

done
END=$(date +%s);
echo $((END-START)) | awk {print int($1/3600)":"int($1%3600/60)":"int($1%3600%60)}

 

脚本shell每小时递增运行task

标签:

原文地址:http://www.cnblogs.com/lasclocker/p/5909350.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!