Java Cron Jobs

Need to run a CRON Job in Java? Try out JobRunr for all your recurring java CRON jobs!

  • Ronald Dehuysser
  • November 10, 2021

Java Cron Jobs

What are CRON jobs?

CRON or crontab is a command-line utility to run certain tasks periodically at fixed times, dates, or intervals. CRON or crontab was originally created by AT&T Bell Laboratories in May 1975 and is by default now available on every OS. Most developers will know the Linux Crontab or the Windows Task Scheduler.

How are CRON jobs useful?

As a developer, you already might have encountered a business requirement where each morning at 10 o’clock a report needs to be sent via email. This is a typical example where a CRON job comes in handy: using a simple CRON expression (in this case 0 10 * * *), you can make sure the method is executed each morning at 10 o’clock.

How is a CRON expression created?

The CRON time string format exists of five fields that the CRON scheduler converts into a time interval. CRON then uses this interval to determine how often to run the associated task or method.

┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31) or L for last day of the month
│ │ │ ┌───────────── month (1 - 12 or Jan/January - Dec/December)
│ │ │ │ ┌───────────── day of the week (0 - 6 or Sun/Sunday - Sat/Saturday)
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
“* * * * *"

How to run a CRON job in Java?

Today, you have several possibilities to run CRON jobs in Java:

  • there is of course Quartz Scheduler
  • Spring framework has support for scheduled jobs using the @Scheduled annotation
  • and since JobRunr is now also in the picture, you can use JobRunr to run CRON jobs in Java.

What is the benefit of using JobRunr for Java CRON Jobs?

Using JobRunr for your CRON jobs brings some advantages:

  • you can easily create a CRON job in a 1-liner using JobRunr: BackgroundJob.scheduleRecurrently(Cron.daily(), () -> System.out.println("Easy!"));
  • if you are using Spring Framework, Micronaut or Quarkus: this is even easier. You can just add the JobRunr integration of your choice (jobrunr-spring-boot-starter, jobrunr-micronaut-feature or the jobrunr-quarkus-extension) and annotate the method that you want to schedule with the @Recurring annotation:
@Service
public class SampleService {

    @Recurring(id = "my-recurring-job", cron = "*/5 * * * *")
    @Job(name = "My recurring job")
    public void executeSampleJob() {
        // your business logic here
        // you can also conditionally enqueue a new job - better visibility in the dashboard
    }
}
  • it comes with a great UI where you have an overview of all your CRON jobs and where you check whether your CRON task / method finished successfully.
An overview of all recurring jobs with the ability to trigger or delete them
A detailed overview of a succeeded CRON job

The JobRunr Blog

Everything you need to know about
background processing

Explore technical deep-dives, product updates, and real-world examples to help you build, scale, and monitor your Java background jobs.

blog image

April 10, 2026

Observability for Java Background Jobs: Logs, Metrics, and Traces

Background jobs fail silently. This article explores the Java observability ecosystem and shows how to bring logs, metrics, and traces to asynchronous job processing.

Read More Details
blog image

January 14, 2026

JobRunr & JobRunr Pro v8.4

Enhanced Kotlin support with Bazel compatibility, auto-configured serialization, and Micronaut 4.10

Read More Details
blog image

February 24, 2023

JobRunr & JobRunr Pro v6.1.0

An important bugfix and Job Filters improved a lot!

Read More Details
call to action

Try JobRunr yourself, no install required

Walk through 21 hands-on scenarios in our hosted demo and feel how JobRunr handles real-world workflows. Open it in your browser, no setup, no signup.

Launch the interactive demo