To run cron every 5 minutes you need one short line, */5 * * * *. Cron runs the scheduled jobs on Linux and other Unix-like servers (backups, cache clearing, nightly reports), and its five-field syntax is hard to read at first. This guide shows how to set up a cron job every 5 minutes, how the slash (step) operator works, how to offset or limit the schedule, and gives you a cheat sheet to paste into our Cron Expression Generator.
What is the cron expression to run every 5 minutes?
The cron expression to run a task every 5 minutes is */5 * * * *. In this syntax, the first column (minutes) uses the 'step' operator */5, which means 'every minute that is a multiple of 5.' The remaining four asterisks mean every hour, every day of the month, every month and every day of the week. The command runs at 00:00, 00:05, 00:10 and so on around the clock, 288 times a day.
How the 5-minute cron expression works
A standard cron expression has five fields. Here is how */5 * * * * breaks down field by field:
| Field | Value | Meaning |
|---|---|---|
| Minutes | */5 | Every minute divisible by 5 (0, 5, 10...) |
| Hours | * | Every hour |
| Day of month | * | Every day |
| Month | * | Every month |
| Day of week | * | Every day of the week |
The */n syntax is called the step operator. The crontab(5) manual describes it as skipping "the number's value through the range", so */5 walks the minute range 0-59 in steps of 5. For every 15 minutes, use */15.
How to set up a cron job every 5 minutes
- Run
crontab -eto open your user's crontab in a text editor. - Add one line: the five schedule fields, a space, then the command with absolute paths.
- Save and close the editor.
crontabinstalls the new file and cron picks up the change by itself, so there is nothing to restart. - Run
crontab -lto print the installed lines and check yours is there.
Crontab every 5 minutes: the full line
A complete entry that runs a Python script every 5 minutes and keeps its output looks like this:
*/5 * * * * /usr/bin/python3 /home/user/scripts/sync.py >> /home/user/logs/sync.log 2>&1
The system-wide files /etc/crontab and /etc/cron.d/* take one more field: the user to run as, between the schedule and the command, as in */5 * * * * www-data /usr/bin/php /var/www/cron.php. A user crontab edited with crontab -e has no user field, and putting one there makes cron try to run the user name as a command.
Cron every 5 minutes with an offset, between hours or on weekdays
The plain */5 covers most cases. The variations below come up when several jobs share a server or should only run during working hours.
Every 5 minutes starting at minute 2
2-59/5 * * * * runs at :02, :07, :12 and so on up to :57, still 12 times an hour and 288 times a day. The crontab(5) manual allows a step after a range ("0-23/2" is its example for every other hour), and the step counts from the start of the range. Offsets are useful when many jobs use */5: moving one of them to minute 2 keeps them from all starting in the same second.
Our cron generator only accepts *, */n, single numbers, lists and plain ranges, so it reports "Invalid value in minute field: 2-59/5". Type the same schedule as a list instead, which it accepts and every cron implementation reads the same way: 2,7,12,17,22,27,32,37,42,47,52,57 * * * *.
Every 5 minutes except on the hour
5-55/5 * * * * skips minute 0 and runs at :05 through :55, 11 times an hour and 264 times a day. Use it when an hourly job already runs at :00 and you don't want the two to start together.
Every 5 minutes between hours, on weekdays
*/5 9-17 * * 1-5 runs Monday to Friday from 09:00 to 17:55: 108 runs per weekday and 540 per week. Day 1 is Monday and 5 is Friday; cron counts Sunday as 0 (cronie also accepts 7), while the site's generator accepts 0 to 6 only. Paste it into the generator and the description reads "Minute: */5, Hour: 9-17, on day-of-week 1-5", with the next five run times underneath.
For a window that crosses midnight, write two ranges: */5 22-23,0-5 * * * runs from 22:00 to 05:55, 96 times a night. The generator rejects a backwards range such as 22-5.
| Schedule | Expression | Runs per hour | Runs per day |
|---|---|---|---|
| Every 5 minutes | */5 * * * * | 12 | 288 |
| Every 5 minutes, offset by 2 | 2-59/5 * * * * | 12 | 288 |
| Every 5 minutes except :00 | 5-55/5 * * * * | 11 | 264 |
| Weekdays, 09:00 to 17:55 | */5 9-17 * * 1-5 | 12 (in those hours) | 108 (weekdays only) |
| Nightly, 22:00 to 05:55 | */5 22-23,0-5 * * * | 12 (in those hours) | 96 |
Common cron intervals cheat sheet
Paste any of these into the expression box of our online cron generator to see a plain-English description and the next five run times. The generator also has presets for most of them, and the developer tools page lists the other converters and formatters on the site.
| Schedule | Cron expression |
|---|---|
| Every minute | * * * * * |
| Every 5 minutes | */5 * * * * |
| Every 15 minutes | */15 * * * * |
| Every hour (at minute 0) | 0 * * * * |
| Twice a day (12 AM and 12 PM) | 0 0,12 * * * |
| Every night at midnight | 0 0 * * * |
| Every Monday at midnight | 0 0 * * 1 |
| First day of the month | 0 0 1 * * |
Why */7 does not mean every 7 minutes
A step restarts at the top of every hour. */7 matches minutes 0, 7, 14, 21, 28, 35, 42, 49 and 56, and then 0 again, so the gap from :56 to the next run is 4 minutes. The crontab(5) manual says "steps are evaluated just within the field they are applied to" and gives */23 in the hour field as the example: it runs at hour 0 and hour 23, not every 23 hours.
Only steps that divide 60 evenly give equal gaps in the minute field: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20 and 30. Five is on that list, so */5 stays exactly 5 minutes apart, including from :55 to the next hour's :00. For a true 7-minute interval, use a scheduler that counts time since the last run, such as a systemd timer with OnUnitActiveSec=7min.
Cron every 5 minutes with 6 fields (Spring and Quartz)
Java schedulers add a seconds field at the front, so the 5-field expression doesn't work there. Spring's documentation describes six fields: second, minute, hour, day of month, month and day of week. Quartz uses the same order with an optional seventh field for the year, and needs a ? in either the day-of-month or the day-of-week field.
Standard cron (5 fields): */5 * * * *
Spring (6 fields): 0 */5 * * * *
Quartz (6 or 7 fields): 0 0/5 * * * ?
Spring annotation: @Scheduled(cron = "0 */5 * * * *")
The leading 0 pins each run to second 0 of the minute. Leave it out and write */5 * * * * * in Spring, and the step lands in the seconds field: the task runs every 5 seconds. Quartz numbers the days of the week 1 to 7 starting with Sunday, so weekdays there are 2-6 or MON-FRI. Our generator works with standard 5-field cron only; a 6-field expression gets the message "A cron expression must have exactly 5 fields."
What if the job takes longer than 5 minutes?
Cron starts a new copy whenever the clock matches, whether or not the previous run has finished. A job that sometimes takes 7 minutes will overlap with itself. Wrapping the command in flock from util-linux stops that:
*/5 * * * * /usr/bin/flock -n /tmp/sync.lock /usr/bin/python3 /home/user/scripts/sync.py
With -n, a second copy that can't get the lock exits at once instead of waiting. Two more checks help with jobs that run this often. If the job calls an API with a cached access token, compare the token's exp claim with your schedule; a token that lasts one hour covers 12 runs, and decoding a JWT safely shows how to read that claim. If you tag each run with an ID in your logs, a random v4 from the UUID generator is enough for uniqueness, while a v7 also sorts by start time (see UUID v4 vs v7).
Tips for cron scheduling
- Check your timezone. Servers often run on UTC. If you schedule a backup for
0 0 * * *(midnight), it runs at midnight UTC, which is 4 PM the day before in UTC-8 or 8 AM in UTC+8. The cron generator lists its next run times in your computer's time zone, not the server's, and the Unix timestamp converter shows any timestamp in UTC, your browser's local time or another time zone from its list. - Avoid running a job every minute if you can. Unless it's a high-frequency queue worker, every 5 or 15 minutes is much kinder to your server's CPU and database.
- Log your output. Cron doesn't show a job's output anywhere; cronie mails it to the crontab's owner (or to
MAILTO), and on a server without mail set up you never see it. Append>> /path/to/logfile.log 2>&1to your command so you can debug when things don't fire. - Use absolute paths. The cron environment is minimal; cronie sets
SHELLto/bin/shby default. Instead ofpython script.py, use/usr/bin/python3 /home/user/script.py.
Frequently asked questions
Does */5 * * * * mean every 5 minutes starting now?
No. Cron is clock-based, not interval-based. It runs when the clock's minute matches the expression. If you save the cron at 12:03, it won't run at 12:08; it runs at 12:05, because 05 is the next minute divisible by 5.
What is the difference between */5 and 0,5,10,15...?
In the minute field, nothing. Both run at minutes 0, 5, 10 and so on up to 55. */5 is just shorter to write.
Can I use 'every 5 minutes' only during certain hours?
Yes. */5 9-17 * * * runs every 5 minutes from 09:00 to 17:55, because ranges in cron are inclusive and the hour 17 counts in full. To stop at 17:00, use */5 9-16 * * * plus a second line, 0 17 * * *.