问题描述
我正在尝试安排要在Bigquery UI中当日运行的查询.根据Google的文档,此选项使用cron语法.我已经使用crontab guru来验证语法是否正确,尽管您将调度程序放在什么语法上似乎不接受任何语法都没有关系.这是一个已知的错误?以下是我每6个小时运行一次的cron语法.
0 */6 * * *
接受的答案不会直接链接到正确的文档,也不会解释有效的选项,只是给出了工具提示中已经提供的少量示例(但是确实回答了张贴的特定问题)
这篇文章试图为那些可能遇到类似问题的人提供一个更笼统的答案.
可以直接此处以及相关资料此处位于时间表"下,字段信息 ..
为进行全面披露,我将在此处直接从该文档中摘录一些内容,以便使此答案可以独立".
通常,时间表必须采用以下格式:
[TYPE] [INTERVAL_VALUE] [INTERVAL_SCOPE]
,并且您必须决定要使用三种不同类型的间隔中的哪一个:
- 结束时间间隔
- 开始时间间隔
- 自定义间隔
间隔类型由您提供的时间表隐式选择.
结束时间间隔
这些是从作业完成时开始的时间间隔.
TYPE
每日间隔必须以"每个
"开始前缀
INTERVAL_VALUE
有效时间单位如下:
-
分钟
或分钟
-
小时
INTERVAL_SCOPE
不适用于结束时间间隔.
示例
如果每5分钟",并且作业在0201处完成,则下一个作业在完成后等待5分钟以再次开始,并从0206开始.
开始时间间隔
严格的查询时间表.
TYPE
每日间隔必须以"每个
"开始前缀
INTERVAL_VALUE
以下时间单位的一些整数:
-
分钟
或分钟
-
小时
即使使用1作为数量单位也保持不变.
INTERVAL_SCOPE
必须采用以下形式:
从[HH:MM]到[HH:MM]
,HH = 00,01,...,23和MM = 00,01,...,59.或者已同步
已同步
重复一个时间间隔,并将其均匀地分布在24小时内(例如,像结束时间安排,但将其固定为开始时间).
与此选项一起提供的[INTERVAL_VALUE]必须是24的因子(1、2、3、4、6、8、12或24),以使每一天都有相同的时间表(否则,您将在第二天收到溢出".
示例
示例1:从10:00到14:00每5分钟
如果作业从1000开始并耗时6分钟,则它将运行1000、1010、1020,...,因为1005、1015,...由于作业仍在运行而被跳过.
直接报价:
示例2: 每2小时同步
运行0000,0200,0400,...,2200.
自定义间隔
这些用于指定日或月级别的时间间隔,而不能指定次日时间间隔.
TYPE
-
使用
每个
指定一个重复间隔:-
每天06:00
-
每个星期一
-
每周二
- ...
-
每个星期天
-
-
特定日期可以用序号(
1st
,2nd
,3rd
,OR,first
,second
,third
,...,直至31st
或thirtyfirst
)-
第一,第二个星期二
-
每月第二个第三个星期三09:00
-
请注意,序号和单词可以混合使用.
INTERVAL_VALUE 有效日期是以下各项的任意组合:
-
星期一
或mon
-
星期二
或星期二
-
星期三
或星期三
-
星期四
或thu
-
星期五
或fri
-
星期六
或sat
-
星期日
或sun
一周中所有天的 -
day
INTERVAL_SCOPE 可以包含
-
每月[HH:MM]
-
jan,feb,sep,nov [HH:MM]
,即以逗号分隔的月份列表
请注意,时间必须指定给定的月份,并按上述方式分别给出 HH
和 MM
(分别为00-23和00-59).如果"of"为"of",则表示"of".排除在外,该作业每月运行.
允许的值:
-
一月
或jan
-
2月
或feb
-
march
或mar
-
april
或apr
-
可能
-
june
或jun
-
july
或jul
-
八月
或aug
-
9月
或sep
-
十月
或oct
-
11月
或nov
-
十二月
或dec
一年中所有月份的 -
month
示例
-
第二个星期一,星期四
-
每月09:00的1,8,15,22
-
周一,周三,9月,10月,11月1日(周四)17:00
请注意,在未明确指定时间(例如第二个星期一,星期四
)的情况下,找不到描述工作运行时间的文档.
一般示例
-
第二个星期一,星期四
->自定义间隔" -
第三秒,第二十二秒,30日星期一
->自定义间隔" -
1月1日,4月,7月,10月00:00
->自定义间隔" -
9月,10月,11月1日的第一周一
->自定义间隔" -
每月04:00的第一,第三周一
->自定义间隔" -
每月09:00的1,8,15,22
->自定义间隔" -
每个星期一09:00
->自定义间隔" -
从10:00到14:00的每5分钟
->开始时间间隔" -
从08:00到16:00每1个小时
->开始时间间隔" -
每2个小时同步一次
->开始时间间隔" -
每5分钟
->结束时间间隔" -
每1个小时
->结束时间间隔"
重要提示:
- 输入时间表时会隐式选择时间间隔类型
- 您不能混合使用不同间隔类型的选项.
- 所有指定时间均为世界标准时间
I am trying to schedule a query to run intraday in Bigquery UI. According to Google's documentation this option uses cron syntax. I have used crontab guru to verify the syntax is correct, although it doesn't matter what syntax you put the scheduler doesn't seem to accept any. Is this a known bug? Below is the cron syntax I'm using to run every 6 hours.
0 */6 * * *
The accepted answer does not link directly to the correct documentation nor explain the valid options, except to give a small number of examples already provided by the tooltip (but it does answer the specific question posted)
This post attempts to give a more general answer for those that may follow with similar questions.
A full description of the allowed syntax can be found directly here as well as related materials here under "schedule" field information..
For full disclosure, I'm going to lift out some parts directly from that documentation here so this answer can "stand alone".
Generally, the schedule must be of the form:
[TYPE] [INTERVAL_VALUE] [INTERVAL_SCOPE]
and you must decide which of the three different kinds of intervals you will use:
- End-time intervals
- Start-time intervals
- Custom intervals
The kind of interval is chosen implicitly by the schedule you provide.
End-Time Intervals
These are intervals implemented from when a job finishes.
TYPE
Daily intervals must start with the "every
" prefix
INTERVAL_VALUE
Valid units of time are as follows:
minutes
ormins
hours
INTERVAL_SCOPE
Not applicable for end-time intervals.
Example
If "every 5 mins
", and the job finishes at 0201, then then next job waits 5 minutes AFTER completion to begin again, and starts at 0206.
Start-Time Intervals
A strict schedule for the queries to follow.
TYPE
Daily intervals must start with the "every
" prefix
INTERVAL_VALUE
Some integer amount of the following units of time:
minutes
ormins
hours
The units remain the same even using 1 as the amount.
INTERVAL_SCOPE
Must be of the form:
from [HH:MM] to [HH:MM]
with HH=00,01,...,23 and MM=00,01,..., 59.ORsynchronized
synchronized
repeats a time interval and spreads it evenly across the 24 hour period (e.g. like end-time scheduling but fixing it to a start-time).
The [INTERVAL_VALUE] given in conjunction with this option must be a factor of 24 (1, 2, 3, 4, 6, 8, 12, or 24), presumably so that each day has the same schedule (otherwise, you would get a "spill" over into the next day).
Examples
Example 1: every 5 minutes from 10:00 to 14:00
If the job starts at 1000, and takes 6 minutes, then it will run 1000, 1010, 1020, ..., because the 1005,1015, ..., jobs were skipped because they were still running.
Direct quote:
Example 2: every 2 hours synchronized
Runs 0000,0200,0400, ..., 2200.
Custom Intervals
These specify intervals on the day or month level, and cannot specify sub-daily intervals.
TYPE
Using
every
specifies a repeating interval:every day 06:00
every monday
every tuesday
- ...
every sunday
Specific days can be specified with ordinal numbers (
1st
,2nd
,3rd
, OR,first
,second
,third
, ..., up to31st
ORthirtyfirst
)1st,3rd tuesday
2nd, third wednesday of month 09:00
Note that the ordinal number and words can be mixed.
INTERVAL_VALUEValid days are any mix of the following:
monday
ormon
tuesday
ortue
wednesday
orwed
thursday
orthu
friday
orfri
saturday
orsat
sunday
orsun
day
for all days of the week
INTERVAL_SCOPECan include
of month [HH:MM]
of jan,feb,sep,nov [HH:MM]
i.e. a comma-separated list of months
Note, a time must be given with any given month, with HH
and MM
given as above (00-23 and 00-59, respectively). If "of" is excluded, the job runs every month.
Allowed values:
january
orjan
february
orfeb
march
ormar
april
orapr
may
june
orjun
july
orjul
august
oraug
september
orsep
october
oroct
november
ornov
december
ordec
month
for all months in the year
Examples
2nd monday,thu
1,8,15,22 of month 09:00
1st mon,wednesday,thu of sep,oct,nov 17:00
Note, there is no documentation that could be found describing the time a job runs when the time is not explicitly specified (e.g. 2nd monday,thu
).
General Examples
second monday,thu
-> "Custom Interval"third, twentysecond, 30th mon
-> "Custom Interval"1 of jan,april,july,oct 00:00
-> "Custom Interval"1st monday of sep,oct,nov 09:00
-> "Custom Interval"1st,third monday of month 04:00
-> "Custom Interval"1,8,15,22 of month 09:00
-> "Custom Interval"every monday 09:00
-> "Custom Interval"every 5 minutes from 10:00 to 14:00
-> "Start-time Interval"every 1 hours from 08:00 to 16:00
-> "Start-time Interval"every 2 hours synchronized
-> "Start-time Interval"every 5 minutes
-> "End-time Interval"every 1 hours
-> "End-time Interval"
IMPORTANT:
- Interval types are chosen implicitly when you enter the schedule
- You can't mix and match the options for the different interval types.
- All specified times are UTC
As said in the intro above, this information is essentially ripped from the existing documentation, but I felt that was buried away and that this question deserved a "stand alone" reference text.
这篇关于不接受Bigquery自定义计划Cron语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!