It appears to me that both mean "any of the available values". What exactly in the difference between them?
A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule. These fields, separated by white space, can contain any of the allowed values with various combinations of the allowed characters for that field.
Cron Expressions are, in most cases, a string of five fields, which make up the building blocks of every Cron expression. Each field represents a specific time unit, so that the different fields represent minutes, hours, days of the month, months, and days of the week respectively:
Cron Expression Format : A cron expression is simple a string comprised of anywhere between 6 and 7 fields, each field separated by white space. The most common cron expressions consisting of 7 fields, denoting the various denominations of time, is specified below.
Cron Expressions. Cron expressions are used to configure instances of CronTrigger, a subclass of org.quartz.Trigger. A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule. These fields, separated by white space, can contain any of the allowed values with various ...
*
means every possible value in the field. ?
means you don't care about the value. It's used when you have two fields that may contradict each other. The common example being the day of month and day of week fields. Consider, for example a cron specification for running at 10AM on the first day of every month:
0 0 10 1 * ? *
Now let's break it down:
0
- we want it to run on 10:00:00
0
- we want it to run on 10:00:0010
- we want it to run on 10:00:001
- we want it to run of the 1st of every month*
- we want it to run on every month (e.g., January 1st, February 1st, etc.)?
- we don't care about the day of week. The cron should run on the 1st of every month, regardless of whether it's a Sunday, a Monday, etc.*
- we want it to run on every yearFrom Quartz Scheduler
* ("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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With