There were a old post about Crontab, however, the cron expression is bit different with Spring Cron.
However, it’s not that different, quite similar.
Folliwing is from Quartz document, I just copy few frequently used. Read more at here
Spring Quartz Cron Expression
* * * * * * *
- - - - - - -
| | | | | | |
| | | | | | |- Year (Optional 1970 - 2099)
| | | | | |--- Day-of-Week ( 1 - 7 or SUN - SAT )
| | | | ------ Month ( 1 - 12 or JAN - DEC )
| | | -------- Day-of-Month (1 - 31)
| | ---------- Hours (0 - 23)
| ------------ Minutes (0 - 59)
-------------- Seconds (0 - 59)
The Wildcard
- “*” (“all values”) used to select all values within a field. For example, “” in the minute field means *“every minute”.
- ”?” (“no specific value”) useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don’t care what day of the week that happens to be, I would put “10” in the day-of-month field, and “?” in the day-of-week field. See the examples below for clarification.
- ”-“ used to specify ranges. For example, “10-12” in the hour field means “the hours 10, 11 and 12”.
- ”,” used to specify additional values. For example, “MON,WED,FRI” in the day-of-week field means “the days Monday, Wednesday, and Friday”.
- ”/” used to specify increments. For example, “0/15” in the seconds field means “the seconds 0, 15, 30, and 45”. And “5/15” in the seconds field means “the seconds 5, 20, 35, and 50”. You can also specify ‘/’ after the ‘’ character - in this case ‘’ is equivalent to having ‘0’ before the ‘/’. ‘1/3’ in the day-of-month field means “fire every 3 days starting on the first day of the month”.
Examples
- 0 0 12 * * ? Fire at 12pm (noon) every day
- 0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
- 0 * 14 * * ? Fire every minute starting at 2pm and ending at 2:59pm, every day
- 0 0/5 14 * * ? Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
- 0 10,44 14 ? 3 WED Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
- 0 15 10 ? * MON-FRI Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday