What Is Cron?
Cron is a time-based job scheduler found in Unix and Unix-like operating systems including Linux, macOS, and BSD. It was originally written by Ken Thompson for Version 7 Unix in 1979 and has been a core part of system administration ever since. The name comes from the Greek word chronos (time).
Cron reads configuration files called crontabs (short for "cron tables") that define commands to be executed at specific times. Each user can have their own crontab, and there is a system-wide crontab in /etc/crontab. The cron daemon (crond) runs in the background, checking every minute whether any scheduled jobs need to be executed.
Cron Expression Syntax: The 5 Fields
A standard cron expression consists of five fields separated by spaces. Each field specifies when the job should run:
┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sunday=0)
│ │ │ │ │
* * * * *The five fields are evaluated together. A job runs when all five fields match the current time. For example, 30 9 * * 1 means "at 9:30 AM on every Monday."
Special Characters in Cron
- Asterisk (
*) — Matches every possible value for that field.* * * * *runs every minute. - Comma (
,) — Specifies a list of values.1,15in the day-of-month field means the 1st and 15th of each month. - Hyphen (
-) — Defines a range.1-5in the day-of-week field means Monday through Friday. - Slash (
/) — Specifies a step value.*/15in the minute field means every 15 minutes (0, 15, 30, 45).2-10/2means every 2nd value from 2 to 10 (2, 4, 6, 8, 10).
Common Cron Expressions
Here are cron expressions that every developer and sysadmin should know:
* * * * *— Every minute0 * * * *— Every hour (at minute 0)0 0 * * *— Every day at midnight0 0 * * 0— Every Sunday at midnight0 9 * * 1-5— Weekdays at 9:00 AM0 0 1 * *— First day of every month at midnight0 0 1 1 *— January 1st at midnight (yearly)*/5 * * * *— Every 5 minutes0 */2 * * *— Every 2 hours0 0 * * 1— Every Monday at midnight
Cron in Linux: The crontab Command
The crontab command is the primary interface for managing cron jobs on Linux and macOS:
# View your current crontab
crontab -l
# Edit your crontab (opens in $EDITOR)
crontab -e
# Remove your entire crontab
crontab -r
# View another user's crontab (requires root)
crontab -u username -lEach line in a crontab file follows this format:
# m h dom mon dow command
0 3 * * * /usr/local/bin/backup.sh
30 8 * * 1-5 /home/user/scripts/morning-report.py
0 0 1 * * /usr/bin/certbot renew --quietLines starting with # are comments. Environment variables like PATH, SHELL, and MAILTO can be set at the top of the crontab.
Cron vs systemd Timers
On modern Linux distributions that use systemd, an alternative to cron is systemd timers. Here is how they compare:
- Logging. Cron typically sends output via email or to syslog. Systemd timers integrate with
journalctl, providing structured, queryable logs out of the box. - Dependencies. Systemd timers can depend on other units (e.g., wait for the network to be up). Cron jobs have no dependency mechanism.
- Missed runs. Systemd timers can be configured with
Persistent=trueto run missed jobs after a reboot. Cron silently skips jobs that were missed while the system was down (thoughanacronaddresses this). - Simplicity. Cron wins. One line in a crontab vs two systemd unit files (a
.timerand a.service). For simple, recurring tasks, cron is faster to set up. - Precision. Cron's minimum interval is one minute. Systemd timers support sub-second precision with
OnCalendarand monotonic timers.
Cron in the Cloud
The cron expression format has been adopted by numerous cloud services for scheduled tasks:
AWS (CloudWatch Events / EventBridge)
AWS uses a 6-field cron format (adding a year field) for scheduling Lambda functions, ECS tasks, and other resources via CloudWatch Events or EventBridge rules. The syntax is slightly different — for example, ? is used in the day-of-month or day-of-week field to mean "no specific value."
Google Cloud Scheduler
Google Cloud Scheduler uses standard Unix cron syntax (5 fields) to trigger Cloud Functions, Pub/Sub messages, or HTTP endpoints. It supports timezone specification via the --time-zone flag.
Azure Functions
Azure Functions uses a 6-field NCRONTAB format (adding a seconds field at the beginning) for timer triggers. The expression 0 */5 * * * * runs every 5 minutes, where the leading 0 is the seconds field.
Timezone Considerations
Cron jobs run in the timezone of the system where the cron daemon is running. On a server set to UTC, 0 9 * * * means 9:00 AM UTC. On a developer's laptop set to US/Eastern, the same expression means 9:00 AM Eastern.
This matters most during daylight saving time transitions. If your system timezone observes DST, a job scheduled at 2:30 AM might run twice when clocks fall back, or not at all when clocks spring forward. The safest approach for production systems is to set the server timezone to UTC and convert to local time in the application layer.
Frequently Asked Questions
What does each field in a cron expression mean?
The five fields are, from left to right: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-6, where 0 is Sunday). All five conditions must be met for the job to execute.
How do I run a cron job every 5 minutes?
Use */5 * * * *. The */5 in the minute field means "every 5th minute" — the job runs at minutes 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55 of every hour.
Can I use cron expressions with seconds?
Standard Unix cron uses 5 fields and does not support seconds. Some systems (like Quartz Scheduler for Java, Spring, and Azure Functions) extend the format to 6 or 7 fields, adding seconds and sometimes years. This tool parses the standard 5-field format.
What is the difference between * and ??
In standard Unix cron, ? is not used — only * represents "any value." The ? character is specific to the Quartz scheduler and AWS cron syntax, where it means "no specific value" and is used in the day-of-month or day-of-week field to avoid ambiguity.
How do I debug a cron job that is not running?
Common causes: (1) the cron daemon is not running — check with systemctl status cron; (2) the crontab has syntax errors — validate with this tool; (3) the command uses a path or environment variable not available in cron's minimal environment; (4) the output is going to /dev/null or email. Add output redirection to a log file to debug: * * * * * /path/to/script.sh >> /tmp/cron.log 2>&1.
Can I use day names (MON, TUE) or month names (JAN, FEB)?
Some cron implementations accept three-letter abbreviations for days and months (e.g., MON-FRI instead of 1-5). However, this is not universal. For maximum portability, use numeric values. This tool uses the standard numeric format.
Is this tool safe to use?
Yes. Everything runs in your browser. No cron expressions or data are sent to any server. You can use this tool offline after the initial page load.