Every 30 Seconds
*/30 * * * * * 0/30 * * * * ? Runs every 30 seconds (twice a minute). Requires a seconds-aware dialect — Spring or Quartz — because standard Unix cron is minute-precision only.
Use in your stack
{
"schedule": {
"cron": "0/30 * * * * ?",
"timezone": "UTC"
}
}
// 6-field: second minute hour day-of-month month day-of-week
@Scheduled(cron = "*/30 * * * * *")
public void everyThirtySeconds() {
// ...
}
// Simpler for pure intervals:
@Scheduled(fixedRate = 30000) // milliseconds
public void everyThirtySecondsFixedRate() {
// ...
}
Next runs
Pick a timezone to see when this expression fires next.
Next 10 runs
- 012026-07-03T16:51:00.000Z
- 022026-07-03T16:51:30.000Z
- 032026-07-03T16:52:00.000Z
- 042026-07-03T16:52:30.000Z
- 052026-07-03T16:53:00.000Z
- 062026-07-03T16:53:30.000Z
- 072026-07-03T16:54:00.000Z
- 082026-07-03T16:54:30.000Z
- 092026-07-03T16:55:00.000Z
- 102026-07-03T16:55:30.000Z
Variations
Common use cases
- Polling a queue or inbox twice a minute for lower latency than a 1-minute cron.
- Refreshing a cache or health status on a 30-second heartbeat.
- Emitting a keep-alive or liveness ping to a monitoring system.
- Flushing a metrics buffer downstream at a steady twice-per-minute rate.
Gotchas
- **Unix crontab cannot do this.** The 5-field format has no seconds field; its minimum interval is one minute. A common workaround is two crontab lines with `sleep 30` — but a seconds-aware scheduler is cleaner.
- In Spring, `*/30 * * * * *` is the 6-field form (seconds first) — not Unix's `*/30 * * * *`, which means every 30 *minutes*.
- In Quartz, use `0/30 * * * * ?` — `0/30` in the seconds field means "from second 0, every 30 seconds" (so it fires at :00 and :30 of each minute), and `?` fills the unused day-of-week field.
- `@Scheduled(fixedRate = 30000)` (Spring) or `tokio::time::interval` (Rust) expresses the same interval without a cron parser and is often the simpler choice.
- If a run can take longer than 30 seconds, prefer `fixedDelay` or an in-flight guard so runs don't overlap.
Unix cron is minute-precision — five fields, no seconds — so “every 30 seconds” can’t be written as a single crontab line. People often fake it with a second line that runs sleep 30 first, but that’s fragile.
The clean answer is a 6-field, seconds-first dialect:
- Spring
@Scheduled(cron = "*/30 * * * * *")— see the Spring cron reference and the Spring @Scheduled guide. - Quartz
0/30 * * * * ?— see the Quartz cron reference. - On Linux specifically, a systemd timer with
OnCalendar=*:*:0/30also does twice-per-minute without any cron dialect — see systemd timers.
For a pure interval, @Scheduled(fixedRate = 30000) or tokio::time::interval(Duration::from_secs(30)) says “every 30 seconds” without a cron parser.
Frequently asked questions
What is the cron expression for every 30 seconds?
In a seconds-aware dialect, every 30 seconds is `*/30 * * * * *` (Spring) or `0/30 * * * * ?` (Quartz), firing at :00 and :30 of each minute. Standard Unix/crontab cannot do it — with no seconds field, its finest granularity is one minute.
How do I run a cron job every 30 seconds on Linux?
Plain crontab can't schedule sub-minute, but a common workaround is two lines that offset with sleep: `* * * * * /path/job.sh` and `* * * * * sleep 30; /path/job.sh`. Cleaner options are a systemd timer with `OnCalendar=*:*:0/30`, or a seconds-aware scheduler like Spring or Quartz.
Why doesn't `*/30 * * * *` run every 30 seconds?
`*/30 * * * *` is a 5-field Unix expression whose first field is minutes, so it runs every 30 *minutes* (at :00 and :30 of each hour). Unix cron has no seconds field. Every 30 seconds requires a 6-field dialect where the first field is seconds — Spring (`*/30 * * * * *`) or Quartz (`0/30 * * * * ?`).
How do I run something every 30 seconds in Spring Boot?
Use `@Scheduled(cron = "*/30 * * * * *")`, or more simply `@Scheduled(fixedRate = 30000)` (milliseconds). Use `fixedDelay = 30000` if each run should wait for the previous one to finish before the timer restarts.
Browse all cron patterns
Every schedule Cronuru documents, with its expression and code snippets for six dialects.