Every 5 Seconds
*/5 * * * * * 0/5 * * * * ? Runs every 5 seconds. Requires a seconds-aware dialect — Spring or Quartz — because standard Unix cron is minute-precision only.
Use in your stack
# Twelve offset entries would tile the minute, but don't do that.
# One per-minute entry running an internal loop is the honest form:
* * * * * for i in $(seq 12); do /usr/local/bin/poll.sh & sleep 5; done
# The & matters — without it a slow run pushes the whole cadence out.
# Add flock if overlapping runs would be harmful:
# * * * * * for i in $(seq 12); do flock -n /tmp/poll.lock /usr/local/bin/poll.sh & sleep 5; done
# Cleanest on a systemd distro — /etc/systemd/system/poll.timer
# AccuracySec defaults to 1min and MUST be lowered, or systemd
# coalesces all twelve firings into one.
# [Timer]
# OnCalendar=*-*-* *:*:00/05
# AccuracySec=1s
{
"schedule": {
"cron": "0/5 * * * * ?",
"timezone": "UTC"
}
}
// 6-field: second minute hour day-of-month month day-of-week
@Scheduled(cron = "*/5 * * * * *")
public void everyFiveSeconds() {
// ...
}
// Simpler for pure intervals — no cron parser needed:
@Scheduled(fixedRate = 5000) // milliseconds
public void everyFiveSecondsFixedRate() {
// ...
}
Next runs
Pick a timezone to see when this expression fires next.
- 012026-08-19T14:17:15.000Z
- 022026-08-19T14:17:20.000Z
- 032026-08-19T14:17:25.000Z
- 042026-08-19T14:17:30.000Z
- 052026-08-19T14:17:35.000Z
- 062026-08-19T14:17:40.000Z
- 072026-08-19T14:17:45.000Z
- 082026-08-19T14:17:50.000Z
- 092026-08-19T14:17:55.000Z
- 102026-08-19T14:18:00.000Z
Variations
Common use cases
- Polling a fast-changing queue or message broker for new work.
- Updating a live dashboard or real-time metric during development.
- Health-checking a low-latency service that needs sub-minute detection.
- Draining a buffer to a downstream system on a tight cadence.
Gotchas
- **Unix crontab cannot do this in one line.** The 5-field format has no seconds field; its minimum interval is `* * * * *` (every minute). Kubernetes CronJob and GitHub Actions inherit the same limit.
- **Five seconds is where the `sleep`-offset trick stops being reasonable.** Tiling the minute takes twelve crontab entries, eleven of which are sleeping processes, producing twelve log streams for one logical job. At that point you have written a loop and distributed it across a config file — write the loop instead.
- **A systemd timer needs `AccuracySec=1s` here.** It defaults to **1 minute**, so `OnCalendar=*-*-* *:*:00/05` alone will not fire every 5 seconds; systemd coalesces the firings. The timer looks right and runs 12× less often than intended.
- In Spring, `*/5 * * * * *` is the 6-field form (seconds first). Don't confuse it with Unix's 5-field `*/5 * * * *`, which means every 5 *minutes*.
- In Quartz, use `0/5 * * * * ?` — the `0/5` seconds field means "starting at second 0, every 5 seconds," and `?` fills the unused day-of-week field.
- For anything this frequent, a `fixedRate`/`fixedDelay` loop is often simpler and cheaper than a cron parser. Use `@Scheduled(fixedRate = 5000)` in Spring or `tokio::time::interval` in Rust.
- Overlap is a real risk at 5-second cadence — if the job ever takes longer than 5 seconds, runs stack up. Prefer `fixedDelay` (waits for the previous run) or an in-flight guard.
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 5 seconds” simply isn’t expressible. The finest you can schedule is once a minute.
On Linux, the offset trick has run out
At 30 seconds you need two crontab entries. At 10, six. At five seconds you need twelve — eleven of them sleeping processes, producing twelve syslog streams for one logical job. You have written a loop; you’ve just distributed it across a config file.
So write the loop:
* * * * * for i in $(seq 12); do /usr/local/bin/poll.sh & sleep 5; done
Or, better on any systemd distro, use a timer with OnCalendar=*-*-* *:*:00/05 and AccuracySec=1s — that second line is required, because AccuracySec defaults to 1 minute and systemd will otherwise coalesce all twelve firings into one. See systemd timers.
Or use a dialect that has seconds
To go sub-minute you need a 6-field, seconds-first dialect:
- Spring
@Scheduled(cron = "*/5 * * * * *")— see the Spring cron reference and the Spring @Scheduled guide. - Quartz
0/5 * * * * ?— see the Quartz cron reference.
But for an interval this tight, a plain timer is usually the better tool. Spring’s @Scheduled(fixedRate = 5000) and Rust’s tokio::time::interval(Duration::from_secs(5)) both express “every 5 seconds” without a cron parser — and they’re easier to reason about when a run might overrun its window.
Which runtimes can actually go this fast — and which floor at one minute or five — is laid out in the sub-minute scheduling matrix.
Frequently asked questions
What is the cron expression for every 5 seconds?
How do I run a cron job every 5 seconds on Linux?
Why doesn't `*/5 * * * *` run every 5 seconds?
How do I run something every 5 seconds in Spring Boot?
Can Kubernetes CronJob run a job every 5 seconds?
More seconds schedules
Other patterns on the same cadence — or browse every schedule.