BackendBench
Coffee

Home โ€บ Cron errors โ€บ Quartz

Quartz ยท silent bug

Quartz runs a day early: weekday numbers start at Sunday = 1

Why this happens

In Quartz, 1 is Sunday, so 1-5 means Sunday to Thursday. Unix cron numbers Monday as 1, which is why copied expressions end up one day early.

Wrong and right

wrong
0 0 9 ? * 1-5

Runs on: Sun 03 Jan, 09:00, Mon 04 Jan, 09:00, Tue 05 Jan, 09:00, Wed 06 Jan, 09:00, Thu 07 Jan, 09:00, Sun 10 Jan, 09:00, Mon 11 Jan, 09:00

fixed
0 0 9 ? * 2-6

At 09:00 UTC, on Mon, Tue, Wed, Thu and Fri. First runs after 1 Jan 2027 (UTC): Fri 01 Jan, 09:00, Mon 04 Jan, 09:00, Tue 05 Jan, 09:00, Wed 06 Jan, 09:00, Thu 07 Jan, 09:00

How to fix it

  1. Add one to every Unix weekday number, or
  2. write MON-FRI, which works in every dialect and cannot be misread.
  3. Run the expression through a next-run preview to confirm the days.

The Quartz format at a glance

Fields in order: second (0-59), minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (1-7, 1 = Sunday), year (1970-2199, optional).

Quartz uses the JVM default time zone unless you set one: CronScheduleBuilder.cronSchedule(expr).inTimeZone(TimeZone.getTimeZone("UTC")).

The fixed schedule in other systems

If you are moving this schedule to another scheduler, these are the equivalents of 0 0 9 ? * 2-6:

SystemExpression
Spring0 0 9 * * 1-5
Crontab0 9 * * 1-5
Kubernetes0 9 * * 1-5
AWS EventBridge0 9 ? * 2-6 *
Jenkins0 9 * * 1-5
GitHub Actions0 9 * * 1-5
node-cron0 9 * * 1-5
Apache Airflow0 9 * * 1-5
Azure Functions0 0 9 * * 1-5
Google Cloud Scheduler0 9 * * 1-5

Try it yourself

The tester below starts with the fixed expression. Change it and watch the schedule update.

Your week at a glance
fewer more runs

Upcoming runs

#LocalUTCFrom now

Copy-ready code

Frequently asked questions

Why does my job not run on Fridays?

If you wrote 1-5 thinking Monday to Friday, Quartz runs it Sunday to Thursday, so Friday is missed.

More Quartz fixes

See the full Quartz cron builder or convert between formats.

More tools you might need