Cron every minute (* * * * *): how it works and the traps

Open this example in the tool

Try it in the tool

Cron Expression Parser

Read cron schedules in plain English and see when they run next.

Cron Expression Generator

Pick a schedule, get the cron expression and its next run times.

* * * * * means “at every minute of every hour of every day”. All five fields are wildcards, so the job starts once per minute, 1,440 times a day. The cron parser reads it as “Every minute” and lists the next runs, one per minute.

* * * * *  /usr/local/bin/check-queue.sh
│ │ │ │ │
│ │ │ │ └─ day of week (0-7)
│ │ │ └─── month (1-12)
│ │ └───── day of month (1-31)
│ └─────── hour (0-23)
└───────── minute (0-59)

When it is the right schedule

  • A quick health check or heartbeat that pings a monitoring service.
  • A queue processor that picks up a few pending items and exits.
  • Syncing a small amount of data where a minute of delay is fine.

It is the wrong tool for anything that takes noticeable time, needs a result in under a minute, or reacts to events.

Trap 1: overlapping runs

Cron does not wait for the previous run to finish. If a run takes 90 seconds, a second copy starts while the first still works, and they compete for the same rows, files and memory. Wrap the command in flock, which refuses to start when the lock is held:

* * * * * flock -n /tmp/check-queue.lock /usr/local/bin/check-queue.sh >> /var/log/check-queue.log 2>&1

-n makes the second instance exit at once instead of waiting. A job that writes a lock file itself must also remove it on a crash; flock releases the lock when the process dies, so it is the safer choice.

Trap 2: a mailbox full of output

Whatever a cron job prints is mailed to the user (if mail is set up), or lost. Every minute that adds up fast. Send normal output to a log, and keep errors visible:

MAILTO=ops@example.com
* * * * * /usr/local/bin/job.sh >> /var/log/job.log

Here the normal output goes to the log, and only errors (stderr) are mailed. Use 2>&1 on the end to send both to the log instead. Rotate the log, or it will grow without limit.

Trap 3: the environment

Cron starts with a minimal environment: a short PATH, no login profile, /bin/sh as the shell. A command that works in your terminal can fail here. Use absolute paths (/usr/bin/python3), and set PATH or SHELL at the top of the crontab if you need to.

Faster than a minute

Cron cannot go below 60 seconds. Options:

  • systemd timer with OnUnitActiveSec=30s.
  • A long-running worker with its own loop and a sleep, supervised by systemd or a container.
  • A message queue, so that work starts when it arrives instead of being polled.

A less demanding rhythm is every 5 minutes or every hour. To build any expression with menus instead of memory, use the cron builder. Time zones and daylight saving cause surprises for long intervals; see cron and time zones.

Frequently asked questions

Can cron run a job every 30 seconds?

Not directly: the smallest unit is a minute. The usual trick is two entries, one of them with a sleep 30 in front, but a systemd timer with OnUnitActiveSec=30s or a small long-running worker is cleaner.

What happens if the job takes longer than a minute?

Cron starts the next run anyway, so two copies run at once, then three. Guard it with a lock (flock -n) or make the job quick, otherwise a slow run can pile up until the machine runs out of memory.

Why do I get a mail every minute?

Cron mails the output of a job to the owner. A job that prints anything produces a message each minute. Redirect the output to a log file with >> job.log 2>&1, or set MAILTO="" at the top of the crontab.

Is * * * * * bad practice?

Often it is a sign that polling is used where an event would do. For a health check or a queue worker it is fine, if the job is quick and cannot overlap. Look for a webhook, a queue, or a long-running process if the work is heavy.

More in this reference