Spring uses a 6-field cron format starting with seconds. Supports @hourly, @daily, @weekly macros. The zone attribute on @Scheduled sets the timezone.
| Expression | What it means | Typical use |
|---|---|---|
0 */5 * * * * |
Every 5 minutes | Background polling, queue draining. |
0 0 * * * * |
Every hour on the hour | Hourly cache refresh. |
0 0 0 * * * |
Every day at midnight | Daily report email. |
0 0 9 * * MON-FRI |
Weekdays at 9 AM | Business-hours batch. |
0 0 0 1 * * |
First of every month | Monthly billing run. |
@daily |
Macro: midnight daily | Concise shorthand. |
Click any expression to load it into the tool above.
Spring is a long-running JVM application where sub-minute timing is sometimes useful (e.g., metrics collection every 15 seconds). The seconds field is the leftmost.
Use the zone attribute: @Scheduled(cron = "0 0 9 * * MON-FRI", zone = "America/New_York"). Without it, Spring uses the server's default timezone.
fixedDelay waits N ms after the previous task completes. fixedRate fires every N ms regardless of duration. cron fires at calendar times. They're mutually exclusive on a single method.
Check that @EnableScheduling is on your config class. The method must be void, take no args, and be in a Spring-managed bean. If methods run more than once, you may have multiple application contexts (common in tests).
No, you must handle that yourself. By default, Spring uses a single thread for all scheduled tasks. For concurrent execution, configure a TaskScheduler with a larger pool.