Quartz job generator
Choose the job, cron, time zone and misfire policy and get Spring Boot beans, plain Quartz code, or a clustered JDBC quartz.properties.
Quartz job and trigger code without the boilerplate
Quartz is the scheduler behind a large share of enterprise Java applications. It is powerful and verbose: a job class, a JobDetail, a Trigger, a schedule builder, misfire handling, and, once you need more than one node, a JDBC job store with clustering. Each piece has options whose defaults are rarely what you want in production.
This generator writes the code for the shape you pick: a Spring Boot configuration with JobDetail and Trigger beans, plain Quartz code you can call from any application, or a quartz.properties file for a clustered JDBC store. The cron expression is validated with the Quartz rules (six fields, a ? in one of the day fields) and the time zone is checked, so errors show up here instead of at startup.
Decisions to make on purpose
- Misfire instruction: "do nothing" is right for reports and syncs where a late run has no value; "fire once now" gives one catch-up run; "ignore misfires" fires every missed run and can cause a burst after downtime.
- @DisallowConcurrentExecution prevents a slow run from overlapping the next one. Pair it with
@PersistJobDataAfterExecutionwhen the job updates its own JobDataMap. - requestRecovery re-runs a job that was executing when a node crashed. Only enable it for idempotent jobs.
- Time zone: set it explicitly; the default is the JVM's zone, which differs between your laptop and the server.
Quartz and Spring's @Scheduled solve different problems: Quartz persists jobs, supports clustering and misfire policies; @Scheduled is simpler but runs in memory. If you only need to stop a scheduled method from running on every node, see the ShedLock generator. The code is produced in your browser; review it before committing.
Frequently asked questions
What is a Quartz misfire?
A misfire happens when a trigger could not fire on time, for example because all worker threads were busy or the application was down. The misfire instruction decides what Quartz does: skip it, fire once now, or fire every missed run.
What does @DisallowConcurrentExecution do?
It stops two executions of the same JobDetail (same name and group) from running at the same time. Different job keys can still run in parallel, and without a clustered JDBC store the guarantee only holds inside one scheduler instance.
What is storeDurably?
A durable job stays in the job store even when no trigger points to it. Without it, Quartz deletes a job when its last trigger is removed, and Spring Boot beans declared without a trigger would vanish.
Cron expression: which day-of-week numbering does Quartz use?
Quartz numbers days 1 to 7 starting with Sunday, or you can use SUN to SAT. It requires a ? in either day-of-month or day-of-week, and the expression has six fields (seconds first) plus an optional year.