Naar de inhoud
OneKitly

What Is a Cron Expression?

Gepubliceerd op 28-7-2025 · 3 min leestijd · Ontwikkelaarstools

Daniel Okonkwo

Daniel Okonkwo — Front-enddeveloper en techredacteur bij OneKitly

Webprestaties · Bestandsformaten

Getoetst aan 2 bronnen

Profiel bekijken →
Kort gezegd

A cron expression is a short string that schedules a task to run automatically at set times, used by the Unix cron tool and many apps. It has five fields — minute, hour, day of month, month, day of week — so '0 9 * * 1' means 9:00 every Monday. An asterisk means 'every'. It's how servers run backups, reports and cleanups on a schedule.

Advertentie

A cron expression schedules a task to run automatically at set times. Here's what it's for, its five fields, how to read one, and the common gotchas.

What cron is for

Cron is the classic scheduler on Unix and Linux systems, and the same idea now appears in cloud services and app frameworks everywhere. Its job is to run a task automatically at recurring times without anyone pressing a button — nightly database backups, a report emailed every Monday, temporary files cleaned up each hour. Instead of remembering to do these chores, you describe when they should happen in a cron expression, and the scheduler takes care of the rest.

Advertentie

The five fields

A standard cron expression is five values separated by spaces, and their order is fixed: minute (0–59), hour (0–23), day of the month (1–31), month (1–12), and day of the week (0–6, where 0 is Sunday). Each field says when, within its range, the task should fire. Reading left to right, you're moving from the smallest unit of time to the largest and then to the weekday — once you know the order, any expression becomes readable.

Reading an expression

Beyond plain numbers, a few symbols do the heavy lifting. An asterisk means 'every' value of that field. A number means exactly that value. A slash sets a step, so */15 in the minute field means 'every 15 minutes'. A comma lists several values, and a dash gives a range. Put together, '0 9 * * 1' reads as: minute 0, hour 9, any day of the month, any month, on Monday — that is, 9:00 every Monday. Decode field by field and the whole thing falls into place.

Common patterns and gotchas

A few patterns cover most needs: '*/15 * * * *' runs every 15 minutes, '0 0 * * *' every day at midnight, '0 9 * * 1-5' at 9:00 on weekdays. Two things catch people out. When both the day-of-month and day-of-week fields are set, most cron implementations run the job if either matches, not both — a frequent surprise. And cron uses the server's clock, so double-check the timezone, or a 'midnight' job may fire at the wrong hour. When unsure, test the expression against a schedule preview before trusting it.

Cron-expressiegeneratorStel een cron-planning veld voor veld samen — minuut, uur, dag van de maand, maand, dag van de week — en zie de expressie en een beschrijving in gewone taal live meelopen. Voorinstellingen dekken met één klik de gangbare schema's, en de syntaxis (*, */5, 1-5, 1,15) wordt ter plekke uitgelegd.Probeer de tool →
Advertentie

Veelgestelde vragen

What is a cron expression?
A string of fields that tells a scheduler when to run a task automatically.
What does '0 9 * * 1' mean?
Run at 9:00 every Monday.
What does the asterisk mean in cron?
'Every' — every minute, hour, day and so on, for that field.

Artikelen die je misschien interesseren

Alle gidsen →

Vergelijkbare tools

Bronnen

Een fout in dit artikel gezien?