What is a cron job?
A cron job is a scheduled task that runs automatically on a Unix-like system at a defined time or interval. The name comes from cron, a time-based job scheduler built into Linux and macOS. Cron jobs are used to automate repetitive tasks: sending emails, running database backups, clearing caches, polling APIs, generating reports, and any other work that should happen on a regular schedule without human intervention.
Each cron job is defined by a cron expression — a compact string of five fields that tells the scheduler exactly when to run the job. The expression builder above converts those fields into a human-readable description so you can verify the schedule before deploying it.
What is crontab?
Crontab (cron table) is the configuration file where cron jobs are defined on a Unix system. Each line in a crontab file is one scheduled job: a cron expression followed by the command to run. You edit it with crontab -e and list existing jobs with crontab -l. Modern platforms like Cloudflare Workers, AWS EventBridge, GitHub Actions, and Kubernetes CronJobs all use the same five-field cron expression format.
Cron expression syntax
A cron expression has five space-separated fields: minute hour day-of-month month day-of-week. Each field controls one time unit, and combining them defines exactly when the job runs.
Field ranges
- Minute — 0–59
- Hour — 0–23
- Day of month — 1–31
- Month — 1–12 (or JAN–DEC)
- Day of week — 0–6 where 0 is Sunday (or SUN–SAT)
Special characters
*— any value (wildcard): matches every possible value for that field,— list:1,15,30means the 1st, 15th, and 30th-— range:1-5means 1, 2, 3, 4, and 5/— step:*/15means every 15 units;0/15means starting at 0, every 15
Common cron expressions
* * * * *— every minute*/5 * * * *— every 5 minutes*/15 * * * *— every 15 minutes0 * * * *— every hour, on the hour0 9 * * 1-5— 9:00 AM Monday through Friday0 0 * * *— midnight every day0 0 * * 0— midnight every Sunday0 0 1 * *— midnight on the first of every month0 0 1 1 *— midnight on January 1st (yearly)0 2 * * 0— 2:00 AM every Sunday30 23 * * 1-5— 11:30 PM on weekdays0 9,17 * * 1-5— 9:00 AM and 5:00 PM on weekdays
Platform differences
The standard five-field UNIX format is used by Linux crontab, Cloudflare Workers Cron Triggers, and GitHub Actions schedules. AWS EventBridge adds a sixth year field and uses ? as a wildcard for day-of-month or day-of-week (both cannot be specified at once). Kubernetes CronJobs use the standard five-field format. Some platforms add a seconds field at the start, making it a six-field expression — check your platform's documentation.
Frequently asked questions
What is a cron job used for?
Cron jobs automate any task that needs to run on a schedule: database backups, sending digest emails, clearing expired sessions, rotating log files, polling external APIs for updates, generating reports, syncing data between services, running health checks, and triggering deployments. If a task needs to happen at the same time repeatedly, a cron job is the standard solution.
How do I run a cron job every hour?
Use 0 * * * * — minute 0, every hour. The 0 in the minute field means it runs at the top of each hour (00:00, 01:00, 02:00, etc.). To run every 30 minutes use */30 * * * *; every 15 minutes use */15 * * * *.
What does */5 mean in a cron expression?
The / character is a step operator. */5 in the minute field means "every 5 minutes" — starting at 0, then 5, 10, 15, 20, and so on. You can use it in any field: */2 in the hour field means every 2 hours; */3 in the month field means every 3 months.
How do I set up a cron job on Linux?
Run crontab -e to open your crontab file in the default editor. Add one line per job in the format expression command — for example: 0 2 * * * /home/user/backup.sh runs the script at 2 AM daily. Save and exit; cron picks up the changes immediately. Use crontab -l to list all your current jobs and crontab -r to remove them all.
What is the difference between cron and crontab?
cron is the daemon (background service) that runs scheduled jobs. crontab is the configuration file (and command) that defines which jobs cron should run. You interact with crontab to manage schedules; cron runs silently in the background executing them.