Cron every 20 minutes: */20 * * * *
*/20 * * * * runs three times an hour, 72 times a day, at minutes 0, 20 and 40.
At a glance
- Expression
- */20 * * * *
- Fires
- 72 times a day, 3 times an hour, 504 times a week.
- Restricted fields
- Minute only. All other fields are open.
- Equivalent macro
- None.
- Minutes matched
- 0, 20, 40.
- Worst case latency
- 20 minutes for work that arrives just after a run starts.
In detail
Twenty divides an hour into three equal pieces, so the schedule is even across the hour boundary and easy to reason about: minute 0, minute 20, minute 40, then minute 0 of the next hour. Three runs an hour is the point where the fixed cost of starting the job, loading an interpreter, opening connections, reading configuration, stops dominating the useful work.
That startup cost is the usual reason to choose twenty over ten or five. A script that spends eight seconds getting ready and two seconds working is wasting eighty percent of its runtime at every frequency, but at three runs an hour the absolute waste is thirty seconds a day rather than several minutes, and nobody has to rewrite it as a daemon.
The trade is latency. Anything that arrives one minute after a run begins waits nineteen minutes for the next one, so this schedule suits work with a tolerance measured in tens of minutes: cache warming, reconciliation, backfilling a search index. It does not suit anything a person is sitting and waiting for.
Because the three matched minutes include minute 0, the schedule collides with the hourly pile up once every hour rather than once every twenty minutes. Offsetting to 5-59/20 moves all three runs to 5, 25 and 45 past and removes that one collision, which is the cheapest possible fix if the top of the hour is where your database is busiest.
Examples
*/20 * * * *0,20,40 * * * *5-59/20 * * * *Fires at 5, 25 and 45 past.
Things that catch people out
- Three runs an hour makes a failed run expensive, because the gap before the retry is twenty minutes. Add an in script retry rather than waiting for the next schedule.
- */20 in the hour field means hours 0 and 20 only, a two run day, not every twenty hours.
- If the job needs the previous twenty minutes of data, compute that window from the current clock time rounded down, not from now minus twenty minutes, or a late start shifts the window.
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 15 minutes: */15 * * * *
*/15 * * * * fires 96 times a day on the quarter hours. What happens to the count on the two daylight saving days, and how 7-59/15 spreads the load.
Cron every 30 minutes: */30 * * * *
*/30 * * * * fires 48 times a day at minutes 0 and 30. The half hour is the busiest slot on most servers, and 15,45 costs nothing to move to.
Cron every 10 minutes: */10 * * * *
*/10 * * * * fires 144 times a day at minutes 0, 10, 20, 30, 40 and 50. Run counts, offset variants and the rate limit maths that make it popular.
Cron n/step: starting a step from a value you choose
The form 5/15 means start at 5 and step by 15, giving 5, 20, 35 and 50. It is how you move a repeating job off the crowded top of the hour.
Cron every 45 minutes: why */45 * * * * does not do it
*/45 * * * * fires at minute 0 and minute 45 only, so the gaps alternate 45 and 15 minutes. Here is the four line crontab that really runs every 45 minutes.
Cron every 90 minutes: the two line crontab that works
Ninety minutes crosses the hour boundary, so no single cron expression covers it. Two lines stepping the hour field by 3 give an exact 16 run day.
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