我有来自API的数据,我想调用它并每隔4小时(当天数据)将数据转储到我的数据库中.我使用了以下内容:
0 */4 * * *
我的报告中的数据缺少一些值,我认为cronjob是这样调用的:
today 00:00:00 -> should return nothing for today results
today 04:00:00 -> should return data for today
....
today 20:00:00 -> should return data for today
tomorrow 24:00:00 -> should return data for today, but this is tomorrow !
所以我现在想的是这样称呼它:
today 00:00:00 -> should return nothing for today results
today 03:59:59 -> should return data for today
....
today 19:59:59 -> should return data for today
tomorrow 23:59:59 -> should return data for today, but this is tomorrow !
我无法实现这个cronjob.还是有更好的方法?
解决方法:
在crontab中无法使用秒和负时间.只需在前一个小时的第59分钟等待59秒.示例crontab:
#
# minute 0-59
# hour 0-23
# dom 1-31
# mon 1-12 (or names)
# dow 0-7 (0 or 7 is Sun, or use names)
#
59 23,3,7,11,15,19 * * * sleep 59 && /bin/datadump