1

I would like to run the job at each 30 min + 2, such as 9:02 9:32 10:02 ... How to set this in * * * * *?

Hong
  • 365
  • 4
  • 14

3 Answers3

3

You can specify minutes 2 and 32. so it would be

2,32 * * * *
1

I see that there is an accepted answer already but I would like to explain a bit more on that topic.

You already know that you need a specific cron expression to be configured:

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.

The easiest way to describe/generate it would be by using an online tool like for example this one. There you can also find some Cron expression examples for better understanding of the topic.

So in your use case which is:

to run the job at each 30 min + 2, such as 9:02 9:32 10:02

the expression would be: 0 2/30 * ? * * *

which means:

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

and results in:

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

and so on.

I hope that it makes it clear.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
0

You can use it as such

0 2/30 * * * ? *
Robin Tan
  • 121
  • 6
  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – RyanNerd Feb 05 '20 at 06:45