Cron every 10 seconds: */10 * * * * * and the alternative
In a six field expression, */10 in the seconds field fires at seconds 0, 10, 20, 30, 40 and 50, six times a minute and 8,640 times a day.
At a glance
- Expression
- */10 * * * * *
- Fires
- 8,640 times a day, 360 times an hour, 6 times a minute.
- Restricted fields
- Seconds only. Minute, hour, day of month, month and day of week are all open.
- Equivalent macro
- None.
- Seconds matched
- 0, 10, 20, 30, 40, 50.
- Five field workaround
- Six crontab lines, each offset by a sleep of 0, 10, 20, 30, 40 and 50 seconds.
In detail
Ten divides 60 exactly, so the seconds field behaves the same way the minute field does with */10: six evenly spaced matches, and no awkward gap when the minute rolls over. The count follows directly, six a minute times 1,440 minutes is 8,640 runs a day.
The system crontab cannot express this, because it has no seconds field. The traditional workaround is six identical crontab lines that each run every minute, with the first running immediately and the others preceded by sleep 10, sleep 20 and so on. It works, it is genuinely used, and it is also six processes a minute whose only job is to wait.
Before doing that, weigh the alternative. At ten second intervals a persistent process that sleeps between iterations is cheaper in every dimension: no process spawn, no interpreter start, no reconnection, and a place to keep state between runs. Cron is a scheduler for things that happen occasionally, and 8,640 times a day is not occasional.
If the ten second cadence is a requirement rather than a preference, at least make each run cheap and bounded. Give the command a timeout shorter than ten seconds so a hung run cannot overlap the next six, and make sure the log line per run is short, because 8,640 lines a day per host adds up quickly across a fleet.
Examples
*/10 * * * * ** * * * * /opt/app/bin/tick.sh
* * * * * sleep 10; /opt/app/bin/tick.sh
* * * * * sleep 20; /opt/app/bin/tick.sh
* * * * * sleep 30; /opt/app/bin/tick.sh
* * * * * sleep 40; /opt/app/bin/tick.sh
* * * * * sleep 50; /opt/app/bin/tick.shSix entries, each firing once a minute, offset by a sleep.
*/10 * * * * * timeout 9 /opt/app/bin/tick.shThings that catch people out
- The sleep workaround starts all six processes at the top of the minute in the sense that cron forks them together. The load spike is at :00 even though the work is spread out.
- A semicolon in a crontab command is fine, but a percent sign is not. Cron turns an unescaped % into a newline and feeds the rest to the command on stdin.
- Five field parsers reject */10 * * * * * as having too many fields. That is the correct behaviour, not a bug in the expression.
Try it: Cron Expression Parser
Paste any five or six field expression to get a plain English description, a per field breakdown and the next run times in your local time.
Cron Expression Parser
LOCAL · Browser-OnlyParse cron expressions and see the next scheduled run times
Supports 5-field (minute hour day month weekday), 6-field (with seconds), named values (JAN, MON), and @macros (@daily, @hourly, ...)
Use the dropdowns below to build your cron expression visually, or type a custom value in each field.
Human-Readable Description
Every 5 minutes
Field Breakdown
| Field | Allowed | Value | Meaning |
|---|---|---|---|
| Minute | 0-59 | */5 | every 5 minute(s) |
| Hour | 0-23 | * | every hour |
| Day of Month | 1-31 | * | every day of month |
| Month | 1-12 | * | every month |
| Day of Week | 0-7 | * | every day of week |
Related cron expressions
All cron expressions →Cron every 30 seconds: */30 * * * * * and the two line trick
*/30 * * * * * fires at seconds 0 and 30, 2,880 times a day. The classic two line crontab with sleep 30 does the same thing without a seconds field.
Cron every second: * * * * * * with a seconds field
Six asterisks means every second, 86,400 times a day. Standard crontab has no seconds field, so this form only works in schedulers that accept six.
The cron seconds field: the optional sixth position
A six field expression puts seconds first and shifts everything right. The system crontab has no seconds field, so six fields there means a broken job.
Cron every minute: * * * * *
* * * * * fires 1,440 times a day, once at the top of every minute. Why it is the fastest a five field crontab goes, and how to stop runs stacking.
Cron every hour: 0 * * * *
0 * * * * fires 24 times a day at the top of every hour and is what @hourly expands to. Why * */1 * * * is the mistake people make instead.
Cron every hour at 30 minutes past: 30 * * * *
30 * * * * runs 24 times a day at half past every hour. How to pick an offset minute deliberately and why the top of the hour is worth avoiding.
Tools for this
- Cron Expression Parser Free online cron expression parser - parse cron expressions and see the next scheduled run times
- Crontab Generator Free online crontab generator - build cron expressions visually with an intuitive interface