DevRivet

Blog · · Updated

Cron Every 5 Minutes: */5 * * * * and Other Minute Intervals

Use */5 * * * * to run cron every 5 minutes. Covers the step syntax, 15 and 10 minute intervals, and the hour-field mistake that runs jobs every 5 hours.

Cron Expression Generator

Build, understand and validate cron expressions.

Try it free →

To run a cron job every 5 minutes, use the expression */5 * * * *. The first field is the minute, and */5 means every minute value that is a multiple of 5, so the job fires at :00, :05, :10 and so on, every hour of every day.

To check the schedule before you deploy it, paste the expression into the Cron Expression Generator. It explains each field and previews the next run times, which is the fastest way to catch a value in the wrong field.

How the 5 fields work

A standard cron expression has five fields, separated by spaces, in this order:

┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12)
│ │ │ │ ┌─ day of week (0-6, Sunday is 0; 7 is also accepted as Sunday on many systems)
│ │ │ │ │
* * * * *

Each field accepts a value, a range, a list, a step, or * for every allowed value. The minute field is the one that matters for interval schedules because it is the smallest unit. Some schedulers, such as Quartz, use extra fields, including seconds at the front. If your scheduler expects six or seven fields, the expression changes, so check which format your tool uses.

The step syntax: */N

A step is written as range/step. The * stands for the full range of the field, so */5 in the minute field matches 0, 5, 10, up to 55. You can write the same thing with an explicit range, 0-59/5, and it means exactly the same.

The step divides the range into regular intervals starting from the beginning of the range. Use */N or an explicit 0-59/N when you want that behavior. The shorter form N/step (for example 5/15) is covered in its own section below, because it is not portable.

Common minute intervals

These expressions cover the intervals people search for most. Each one runs in every hour of every day unless you restrict the hour or day fields.

  • Every minute: * * * * *
  • Every 2 minutes: */2 * * * *
  • Every 5 minutes: */5 * * * *
  • Every 10 minutes: */10 * * * *
  • Every 15 minutes: */15 * * * * or 0,15,30,45 * * * *
  • Every 30 minutes: */30 * * * * or 0,30 * * * *
  • Once an hour, at minute 0: 0 * * * *

For schedules measured in hours, such as 0 */2 * * * (every 2 hours, on the hour), see Cron Every 2 Hours.

Every 15 minutes: */15 or 0,15,30,45?

Both expressions produce the same run times: :00, :15, :30 and :45. */15 is shorter and easier to change later. The list form 0,15,30,45 is more explicit, and it is easier to edit if you want to skip a slot. For example, 0,15,45 skips :30.

Both forms work in every standard cron implementation. Pick the one your team reads faster.

Portability: avoid N/step without a range

Some cron implementations accept a start value with a step and no explicit range, such as 5/15 or 0/15. Cronie accepts these, but other implementations, including classic Vixie cron, may reject them or read them differently. An expression that works on your laptop can fail on a server.

Use */N or 0-59/N in the minute field instead. Both are accepted everywhere that supports step syntax. If you need a run at an offset, write the range explicitly, such as 2-59/5, which runs at minutes 2, 7, 12 and so on.

*/15 * * * *      portable: :00, :15, :30, :45
0-59/15 * * * *   portable: same run times, explicit range
0/15 * * * *      avoid: not accepted by every cron
2-59/5 * * * *    portable: :02, :07, :12, ...

The common mistake: putting the step in the hour field

The most frequent error is putting the step in the wrong field. Compare these two expressions:

*/5 * * * *    every 5 minutes, every hour
0 */5 * * *    at minute 0, every 5th hour (00:00, 05:00, 10:00, 15:00, 20:00)

The second expression does not run every 5 minutes. It runs once every 5 hours. If your job should run every few minutes, the step belongs in the minute field, and the hour field should be *.

The same mistake happens with the day and month fields. A step in the day-of-month field, such as */2, runs on every other day, not every other hour. Read each field from left to right, and ask what it counts.

Intervals that do not divide 60

Cron resets the minute field at the start of every hour. An interval that does not divide evenly into 60 leaves an uneven gap at the hour boundary. For example, */7 * * * * runs at minutes 0, 7, 14, 21, 28, 35, 42, 49 and 56. The next run is at minute 0 of the next hour, so the gap from 56 to 60 is only 4 minutes.

If you want the same gap all day, pick a step that divides 60 evenly: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20 or 30.

If you need a steady interval that carries across hours, cron's minute field is not the right tool. Use a scheduler that supports fixed delays, or run a loop that sleeps between runs.

Cron runs at minute boundaries, not from the start time

Cron does not count five minutes from the moment you save the crontab or start the process. It fires at clock boundaries. If you add */5 * * * * at 10:03:20, the first run is at 10:05:00, then 10:10:00, 10:15:00, and so on.

This matters when you test. If you expect a job to run right after you add it, it will not. Wait for the next boundary, or run the command by hand to confirm it works. It also means every server with the same schedule fires at the same moment, which can cause load spikes if many jobs use */5. Plain cron syntax cannot spread start times across a fleet, so offset the job explicitly if you need to.

Check the next run times before you deploy

Before you put an expression in production, preview the next runs. The Cron Expression Generator shows upcoming run times and explains each field in plain language. If the preview shows :00 and :05 when you wanted :05 and :10, the field values are off, and you can fix them before the job runs on a server.

For daily or weekly schedules, the same approach works. See Cron Every Day at Midnight for daily examples and Cron Every Monday for weekly ones.

Pitfalls to check

  • A 5-minute job that takes longer than 5 minutes will overlap with the next run unless your scheduler or script prevents it. Use a lock file or check for a running process before starting.
  • Hosted schedulers do not always fire exactly on the boundary. A busy platform can start a run late, so don't rely on a 5-minute job running at the exact second.
  • Check the time zone your scheduler uses. Classic cron follows the server's configured zone, while many hosted schedulers use UTC. Read your platform's documentation, especially around daylight saving time changes.
  • Confirm the field count. A six-field expression with seconds will be misread by a five-field parser, and the reverse is also true.
  • Cron jobs run with a minimal environment. Use absolute paths in the command, and set any environment variables the job needs.

FAQ

How do I run a cron job every 5 minutes only during certain hours?

Restrict the hour field. For example, */5 9-17 * * * runs every 5 minutes from 09:00 through 17:55. The minute step stays in the minute field, and the hour range goes in the hour field.

To limit it to working days as well, add a day-of-week range:

*/5 9-17 * * 1-5

This runs every 5 minutes from 09:00 through 17:55, Monday to Friday. The hour range 9-17 includes the whole 17:00 hour, so the last run of the day is at 17:55, not 17:00. If you want the last run at 17:00, use */5 9-16 * * 1-5 plus a separate 0 17 * * 1-5 line.

Is */5 the same as 0-59/5?

Yes. Both match minutes 0, 5, 10 through 55. */5 is the shorter form, and the explicit range is clearer if your team is new to step syntax.

Why did my every-5-minutes job not run right away?

Cron waits for the next clock boundary, such as 10:05:00 or 10:10:00. It does not start counting from the time you added the job. Wait for the next boundary, or run the command manually to test it.

Can cron run a job every 5 seconds or every 90 seconds?

Not with standard five-field cron, because its smallest unit is one minute. It cannot run anything more often than once a minute, and it cannot repeat on an interval that is not a whole number of minutes. Use a scheduler with second-level support, or a long-running process that sleeps between runs.

Cron Expression Generator

Build, understand and validate cron expressions.

Try it free →