CRON expression difference

Hi

Can anyone tell me the difference between cron expression 0 0 12 ? * MON-WED and 0 0 12 * * MON-WED

Thanks in advance

Hi @Akshaya89

Expression 1: 0 0 12 ? * MON-WED

  • Executes at 12:00 PM on Monday, Tuesday, and Wednesday.
  • ?: Day-of-month is ignored.

Expression 0 0 12 * * MON-WED

  • Executes at 12:00 PM on Monday, Tuesday, and Wednesday.
  • *: Means β€œevery day of the month.”

? ignores the day-of-month, while * explicitly includes all days.

Hope it helps!!

have a look at this online tool which also helps to get more familiar with cron expressions and has a describe functionality


And

where the role of ? vs * can be derrived and is

Asterisks (also known as wildcard) represents β€œall”.

taken from: cron - Wikipedia

1 Like