Back to blog
Automation6 min read

How to Write Cron Expressions

Understand cron syntax, common schedules, and debugging tips for writing reliable cron expressions.

Use the related XKit tool

Open Cron Parser

Cron expressions describe recurring schedules in a compact five-field format. They are used by Linux crontab, Kubernetes CronJobs, GitHub Actions, cloud schedulers, queues, and automation platforms.

The five cron fields

A standard cron expression has five fields: minute, hour, day of month, month, and day of week. The expression 0 9 * * 1 runs at minute 0 of hour 9 on Mondays.

The asterisk means every allowed value. Commas define lists, hyphens define ranges, and slashes define intervals.

  • * * * * * runs every minute.
  • */5 * * * * runs every five minutes.
  • 0 0 * * * runs once per day at midnight.
  • 0 9 * * 1-5 runs every weekday at 9:00.

Timezone and environment gotchas

Cron schedules usually run in the server or platform timezone, not the timezone of the person who wrote the expression. Cloud platforms may default to UTC unless configured otherwise.

If a job runs one hour early or late, check timezone configuration and daylight saving behavior before changing the expression.

How to debug a cron schedule

Start by converting the expression to plain English, then inspect the next run times. Confirm the platform supports the same syntax. Some systems support six fields with seconds, while standard crontab uses five fields.

For critical jobs, document the intended schedule in code comments or runbooks so future changes are easier to review.

Frequently Asked Questions

What does */5 mean in cron?

It means every five units in that field. In the minute field, */5 means every five minutes.

Does cron use local time or UTC?

It depends on the system. Linux crontab usually uses the server timezone. Many cloud schedulers default to UTC.

Can cron run every 30 seconds?

Standard five-field cron cannot represent seconds. Some schedulers support a six-field format, but plain crontab does not.