What is a Cron Expression?
A cron expression is a string of five fields that represents a schedule for running periodic tasks in Unix-like operating systems. The cron daemon reads these expressions and executes commands at the specified times. Cron is one of the most widely used job schedulers, powering everything from database backups to automated deployments.
Cron Syntax Reference
| Field | Allowed Values | Special Characters | Description |
|---|---|---|---|
| minute | 0-59 | * , - / | Minute of the hour |
| hour | 0-23 | * , - / | Hour of the day |
| day of month | 1-31 | * , - / L W | Day of the month |
| month | 1-12 | * , - / | Month of the year |
| day of week | 0-6 (Sun=0) | * , - / L # | Day of the week |
Common Cron Examples
0 0 * * *
Run at midnight every day
*/5 * * * *
Run every 5 minutes
0 9 * * 1-5
Run at 9 AM on weekdays
0 0 1 * *
Run at midnight on the 1st of each month
Cron vs Systemd Timers
While cron remains the classic choice for scheduling tasks, modern Linux systems also offer systemd timers. Systemd timers provide more flexibility with calendar events, monotonic timers, and better logging through journald. However, cron expressions are simpler to write and understand, making them ideal for straightforward scheduling needs. Both are actively maintained and widely used.
Frequently Asked Questions
How do I run a cron job every 30 minutes?
Use the expression */30 * * * *. The */N syntax means "every N units".
What timezone does cron use?
By default, cron uses the system's local timezone. You can set a different timezone per cron job in some implementations by setting the TZ variable.
Can I combine day-of-month and day-of-week?
Yes, but be aware that most cron implementations use OR logic when both fields are specified, not AND. So 0 0 1 * 1 runs on the 1st of the month OR on Mondays.
Is this tool free to use?
Yes, this cron expression generator is completely free with no limits. All processing happens in your browser.