如何在特定的最短时间将 Kubernetes Cronjob 设置为 运行?
How can I set Kubernetes Cronjob to run at a specific min time?
我想运行工作每30分钟+2次,比如9:029:3210:02...
如何在 * * * * *
中设置?
您可以指定第 2 分钟和第 32 分钟。所以它将是
2,32 * * * *
你可以这样使用它
0 2/30 * * * ? *
我看到已经有一个已被接受的答案,但我想就该主题做更多解释。
您已经知道需要配置特定的 cron 表达式:
A cron expression is a string comprising fields separated by white
space that represents a set of times, normally as a schedule to
execute some routine.
实现 describe/generate 的最简单方法是使用在线工具,例如 this one。您还可以在那里找到一些 Cron 表达式示例,以便更好地理解该主题。
所以在你的用例中是:
to run the job at each 30 min + 2, such as 9:02 9:32 10:02
表达式为:0 2/30 * ? * * *
这意味着:
Seconds Minutes Hours Day Of Month Month Day Of Week Year
0 2/30 * ? * * *
At second :00, every 30 minutes starting at minute :02, of every hour
结果:
Wed Feb 05 10:32:00 UTC 2020
Wed Feb 05 11:02:00 UTC 2020
Wed Feb 05 11:32:00 UTC 2020
Wed Feb 05 12:02:00 UTC 2020
Wed Feb 05 12:32:00 UTC 2020
Wed Feb 05 13:02:00 UTC 2020
Wed Feb 05 13:32:00 UTC 2020
Wed Feb 05 14:02:00 UTC 2020
等等。
希望说清楚。
我想运行工作每30分钟+2次,比如9:029:3210:02...
如何在 * * * * *
中设置?
您可以指定第 2 分钟和第 32 分钟。所以它将是
2,32 * * * *
你可以这样使用它
0 2/30 * * * ? *
我看到已经有一个已被接受的答案,但我想就该主题做更多解释。
您已经知道需要配置特定的 cron 表达式:
A cron expression is a string comprising fields separated by white space that represents a set of times, normally as a schedule to execute some routine.
实现 describe/generate 的最简单方法是使用在线工具,例如 this one。您还可以在那里找到一些 Cron 表达式示例,以便更好地理解该主题。
所以在你的用例中是:
to run the job at each 30 min + 2, such as 9:02 9:32 10:02
表达式为:0 2/30 * ? * * *
这意味着:
Seconds Minutes Hours Day Of Month Month Day Of Week Year
0 2/30 * ? * * *
At second :00, every 30 minutes starting at minute :02, of every hour
结果:
Wed Feb 05 10:32:00 UTC 2020
Wed Feb 05 11:02:00 UTC 2020
Wed Feb 05 11:32:00 UTC 2020
Wed Feb 05 12:02:00 UTC 2020
Wed Feb 05 12:32:00 UTC 2020
Wed Feb 05 13:02:00 UTC 2020
Wed Feb 05 13:32:00 UTC 2020
Wed Feb 05 14:02:00 UTC 2020
等等。
希望说清楚。