Blog
Wild & Free Tools

Cron Expression Generator for Spring Boot @Scheduled

Last updated: April 2026 7 min read

Table of Contents

  1. Spring Boot vs Standard Cron: The Key Difference
  2. Common Spring Boot Cron Patterns
  3. Using @Scheduled in Your Java Code
  4. Special Spring Boot Cron Values
  5. Timezone Configuration for @Scheduled
  6. Testing Cron Expressions Before Deploying
  7. Frequently Asked Questions

Spring Boot's @Scheduled annotation takes cron expressions — but Spring uses a 6-field format that adds a seconds field at the start. Most online cron tools generate standard 5-field Unix cron, which won't work directly. This guide clears up the difference and shows you how to build the right expression for your Spring application.

You can use our free cron expression generator to build the 5-field base, then adjust for Spring's 6-field format — or use the platform-specific patterns below.

Spring Boot vs Standard Cron: The Key Difference

Standard Unix cron uses 5 fields: minute, hour, day-of-month, month, day-of-week. Spring Boot's @Scheduled(cron = "...") uses 6 fields, with seconds as the first field:

FieldStandard CronSpring Boot Cron
1Minute (0-59)Seconds (0-59)
2Hour (0-23)Minute (0-59)
3Day of month (1-31)Hour (0-23)
4Month (1-12)Day of month (1-31)
5Day of week (0-6)Month (1-12)
6(not used)Day of week (0-7)

So if you want to run a job every day at 9:00 AM in standard cron, it's 0 9 * * *. In Spring Boot it's 0 0 9 * * * — that leading zero is the seconds field.

Common Spring Boot Cron Patterns for @Scheduled

Here are the most commonly needed Spring Boot cron patterns, ready to paste into your @Scheduled annotation:

ScheduleSpring Boot ExpressionStandard Cron Equivalent
Every minute0 * * * * ** * * * *
Every 5 minutes0 */5 * * * **/5 * * * *
Every 15 minutes0 */15 * * * **/15 * * * *
Every hour0 0 * * * *0 * * * *
Daily at midnight0 0 0 * * *0 0 * * *
Daily at 9 AM0 0 9 * * *0 9 * * *
Weekdays at 9 AM0 0 9 * * MON-FRI0 9 * * 1-5
Every 30 seconds*/30 * * * * *Not supported
First day of month0 0 0 1 * *0 0 1 * *
Weekly on Sunday0 0 0 * * SUN0 0 * * 0

Spring Boot allows day-of-week names (MON, TUE, WED, THU, FRI, SAT, SUN) and month names (JAN through DEC), which makes expressions more readable than number-only formats.

Using @Scheduled in Your Java Spring Boot Code

Here is the basic pattern for scheduling a method in Spring Boot:

@Component
public class ReportScheduler {

    @Scheduled(cron = "0 0 9 * * MON-FRI")
    public void generateDailyReport() {
        // Runs weekdays at 9 AM
    }

    @Scheduled(cron = "0 */15 * * * *")
    public void syncData() {
        // Runs every 15 minutes
    }

    @Scheduled(cron = "0 0 0 1 * *")
    public void monthlyCleanup() {
        // Runs on the 1st of every month at midnight
    }
}

Also remember to add @EnableScheduling to your main application class or a configuration class — otherwise, Spring won't scan for @Scheduled annotations at all.

You can also externalize the cron expression to your application.properties file so you don't need to recompile when changing schedules:

# application.properties
app.report.cron=0 0 9 * * MON-FRI
@Scheduled(cron = "${app.report.cron}")
public void generateDailyReport() { ... }
Sell Custom Apparel — We Handle Printing & Free Shipping

Special Spring Boot Cron Values

Spring Boot supports a few shorthand values beyond the standard numeric format:

These are Quartz-style extensions that standard Unix crontab does not support. Our online generator produces standard 5-field expressions that you convert by prepending a seconds field — typically 0 unless you need sub-minute scheduling.

Timezone Configuration for @Scheduled

By default, Spring uses the JVM's default timezone. If your server runs in UTC but you need jobs to run in EST, configure the timezone explicitly:

@Scheduled(cron = "0 0 9 * * MON-FRI", zone = "America/New_York")
public void generateESTReport() { ... }

Valid timezone IDs are the standard Java timezone identifiers: America/New_York, America/Los_Angeles, Europe/London, Asia/Tokyo, etc. Avoid using short timezone abbreviations like EST or PST — they're ambiguous and sometimes handled inconsistently across JVM versions.

For Docker deployments, you can also set the JVM timezone via the TZ environment variable, but explicit zone attributes in your @Scheduled annotations are more predictable and portable.

Testing Cron Expressions Before Deploying to Spring Boot

Before hardcoding a cron expression into production code, verify it using our free cron expression generator. Enter your desired schedule and it shows you the next 5 execution times so you can confirm it matches your intent.

For the 5-to-6-field conversion, build the expression using the 5-field generator, then prepend a 0 for the seconds field. So the tool output 0 9 * * 1-5 becomes Spring Boot expression 0 0 9 * * MON-FRI.

One common mistake: forgetting that 0/5 * * * * * and */5 * * * * * are both valid in Spring but mean slightly different things. The */5 starts at 0 and fires at 0, 5, 10, 15... The 0/5 also starts at 0 but is more explicit. Both work the same in practice for most cases.

Try It Free — No Signup Required

Runs 100% in your browser. No account, no install, no limits.

Open Free Cron Generator

Frequently Asked Questions

Does Spring Boot use 5-field or 6-field cron expressions?

Spring Boot uses 6-field cron expressions. The extra field at the start is for seconds (0-59). Standard Unix cron uses 5 fields (minute, hour, day, month, weekday). To convert, prepend "0" to a standard expression: "0 9 * * 1-5" becomes "0 0 9 * * MON-FRI".

How do I schedule a Spring Boot job to run every 30 seconds?

Use the expression "*/30 * * * * *" in your @Scheduled annotation. This is only possible with Spring Boot's 6-field format — standard 5-field cron cannot schedule sub-minute intervals.

What does the question mark (?) mean in Spring cron expressions?

The question mark means "no specific value" and is used in the day-of-month or day-of-week field when you want to specify the other but not both. For example, "0 0 9 ? * MON-FRI" means weekdays at 9 AM, with ? indicating you're not specifying a day of month.

How do I set the timezone for a Spring Boot @Scheduled job?

Use the zone attribute: @Scheduled(cron = "0 0 9 * * *", zone = "America/New_York"). Use Java timezone IDs like "America/New_York", "Europe/London", or "Asia/Tokyo" rather than abbreviations like EST or PST.

Launch Your Own Clothing Brand — No Inventory, No Risk