Every 20 Seconds
*/20 * * * * * 0/20 * * * * ? Runs every 20 seconds — at :00, :20, :40 of each minute. Requires a seconds-aware dialect (Spring or Quartz); standard Unix cron is minute-precision only.
Use in your stack
{
"schedule": {
"cron": "0/20 * * * * ?",
"timezone": "UTC"
}
}
// 6-field: second minute hour day-of-month month day-of-week
@Scheduled(cron = "*/20 * * * * *")
public void everyTwentySeconds() {
// ...
}
// Simpler for pure intervals — no cron parser needed:
@Scheduled(fixedRate = 20000) // milliseconds
public void everyTwentySecondsFixedRate() {
// ...
}
Next runs
Pick a timezone to see when this expression fires next.
- 012026-07-13T16:05:20.000Z
- 022026-07-13T16:05:40.000Z
- 032026-07-13T16:06:00.000Z
- 042026-07-13T16:06:20.000Z
- 052026-07-13T16:06:40.000Z
- 062026-07-13T16:07:00.000Z
- 072026-07-13T16:07:20.000Z
- 082026-07-13T16:07:40.000Z
- 092026-07-13T16:08:00.000Z
- 102026-07-13T16:08:20.000Z
Variations
Common use cases
- Polling a moderately active queue or message broker.
- Refreshing a live metric or status panel during development.
- Sub-minute health checks with a 20-second detection window.
- Periodically flushing a small buffer to a downstream system.
Gotchas
- **Unix crontab cannot do this.** The 5-field format has no seconds field; its minimum is `* * * * *` (every minute). Kubernetes CronJob and GitHub Actions inherit the same limit.
- In Spring, `*/20 * * * * *` is the 6-field form (seconds first). Don't confuse it with Unix's 5-field `*/20 * * * *`, which means every 20 *minutes*.
- In Quartz, use `0/20 * * * * ?` — the `0/20` seconds field means "starting at second 0, every 20 seconds," and `?` fills the unused day-of-week field.
- For a pure interval, a `fixedRate`/`fixedDelay` loop is simpler than a cron parser. Use `@Scheduled(fixedRate = 20000)` in Spring or `tokio::time::interval` in Rust.
- Because 60 divides evenly by 20, the runs land cleanly at :00, :20, :40 — no drift within the minute.
Standard cron — the kind in /etc/crontab, Kubernetes CronJobs, and GitHub Actions — has five fields starting at minutes. There is no seconds field, so “every 20 seconds” isn’t expressible. The finest you can schedule is once a minute.
To go sub-minute you need a 6-field, seconds-first dialect:
- Spring
@Scheduled(cron = "*/20 * * * * *")— see the Spring cron reference and the Spring @Scheduled guide. - Quartz
0/20 * * * * ?— see the Quartz cron reference.
For an interval this tight, a plain timer is usually the better tool. Spring’s @Scheduled(fixedRate = 20000) and Rust’s tokio::time::interval(Duration::from_secs(20)) both express “every 20 seconds” without a cron parser — and they’re easier to reason about when a run might overrun its window. See also every 15 seconds and every 30 seconds.
Frequently asked questions
What is the cron expression for every 20 seconds?
Why doesn't `*/20 * * * *` run every 20 seconds?
How do I run something every 20 seconds in Spring Boot?
Can Kubernetes CronJob run a job every 20 seconds?
Browse all cron patterns
Every schedule Cronuru documents, with its expression and code snippets for six dialects.