Invalid cron syntax error when scheduling multiple values in a job’s day-of-week field

Use job linkage to manage each day-of-week requirement individually.

Written by vidya.sagamreddy

Last published at: June 17th, 2025

Problem

You want to schedule a job using the cron expression (0 0 14 ? * x#y,x#y) where x is the day of the week and y is the occurrence of that day in the month (first, second, and so on). As an example, you might write (0 0 14 ? * 3#1,3#3) to schedule the job for the first and third Tuesday of the month. 

When you try to run your job using this expression, you receive an error. 

"Invalid Quartz Cron Expression."

 

Cause

Quartz allows only one x#y expression in the day-of-week field. A cron expression with two # expressions in the same field is invalid syntax and rejected by the scheduler.

 

Solution

Use job linkage to manage each day-of-week requirement individually.

Schedule the first job to run on the first desired day of the month using the valid cron expression: 0 0 14 ? * x#y.

For quick reference: 

  • Sunday: 1 
  • Monday: 2
  • Tuesday: 3
  • Wednesday: 4
  • Thursday: 5
  • Friday: 6
  • Saturday: 7

 

Then configure a separate job to execute the first job on the second desired day of the month.