What is Cron?
Cron is a time-based job scheduler found in Unix and Unix-like operating systems such as Linux and macOS. It allows users to schedule commands or scripts to run automatically at specified intervals — every minute, hourly, daily, weekly, monthly, or any custom combination. The name comes from the Greek word “chronos,” meaning time.
Cron jobs are defined in a file called the crontab (cron table). Each line in a crontab file represents a single scheduled task and consists of a cron expression (the schedule) followed by the command to execute. System administrators, developers, and DevOps engineers rely on cron for log rotation, backups, monitoring, sending emails, data synchronization, and countless other automated tasks.
Cron Expression Syntax
A standard cron expression is made up of five fields separated by spaces. Each field specifies when the task should run for that unit of time:
The minute field accepts values 0–59. The hourfield uses 24-hour time (0–23). The day of monthranges from 1–31. The monthfield accepts 1–12 or three-letter abbreviations (JAN–DEC). The day of weekfield accepts 0–6 (Sunday=0) or abbreviations (SUN–SAT).
Each field can use special characters: *means “every,” , separates a list of values, - defines a range, and / specifies a step interval.
Common Cron Expressions
| Expression | Description |
|---|---|
| * * * * * | Every minute |
| */5 * * * * | Every 5 minutes |
| */15 * * * * | Every 15 minutes |
| 0 * * * * | Every hour (at minute 0) |
| 0 */2 * * * | Every 2 hours |
| 0 0 * * * | Every day at midnight |
| 0 6 * * * | Every day at 6:00 AM |
| 0 9 * * 1-5 | Weekdays at 9:00 AM |
| 0 0 * * 0 | Every Sunday at midnight |
| 0 9 * * 1 | Every Monday at 9:00 AM |
| 0 0 1 * * | First day of every month at midnight |
| 0 0 1 1 * | January 1st at midnight (yearly) |
| 30 4 * * * | Every day at 4:30 AM |
| 0 22 * * 5 | Every Friday at 10:00 PM |
| 0 0 15 * * | 15th of every month at midnight |
How to Use Crontab
On Linux and macOS, you can edit your personal crontab by running crontab -e in your terminal. This opens a text editor where each line follows the format: five time fields, then the command to execute.
For example, to run a backup script every day at 2:30 AM, you would add: 30 2 * * * /home/user/backup.sh. To list your current cron jobs, run crontab -l. System-wide cron jobs can be placed in /etc/crontab or the /etc/cron.d/ directory.
Cron in Modern Environments
CI/CD Pipelines
GitHub Actions, GitLab CI, and other platforms use cron syntax to schedule workflows. For example, running nightly builds or periodic security scans.
Cloud Functions
AWS CloudWatch Events, Google Cloud Scheduler, and Azure Timer Triggers all use cron expressions to schedule serverless function execution.
Container Orchestration
Kubernetes CronJobs use cron syntax to schedule containerized workloads like database maintenance, report generation, and cache warming.
Task Queues
Systems like Celery (Python), Sidekiq (Ruby), and Bull (Node.js) support cron-based periodic task scheduling for background job processing.
Database Maintenance
Scheduled cron jobs handle database backups, index rebuilding, partition management, and data archiving at optimal times.
Monitoring & Alerts
Health checks, uptime monitoring, and alert digests are commonly scheduled via cron to run at regular intervals.
Frequently Asked Questions
A cron expression is a string of five fields separated by spaces that defines a schedule for automated tasks. The five fields represent minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-6). Special characters like *, /, -, and , allow you to specify complex schedules like "every 15 minutes" or "weekdays at 9 AM."
The */5 syntax means "every 5th value." In the minute field, */5 means every 5 minutes (0, 5, 10, 15, ..., 55). In the hour field, */5 means every 5 hours (0, 5, 10, 15, 20). The slash (/) is the step operator — the value before it is the start (or * for the field's minimum), and the value after it is the step increment.
Standard Unix cron uses 5 fields: minute, hour, day of month, month, and day of week. Some systems (like Quartz scheduler used in Java, or Spring) add a 6th field for seconds at the beginning, and sometimes a 7th field for year at the end. This tool supports the standard 5-field format used by crontab, most CI/CD systems, and cloud schedulers.
Use the day-of-week field (the 5th field) with a range of 1-5, where 1 is Monday and 5 is Friday. For example, "0 9 * * 1-5" runs at 9:00 AM Monday through Friday. You can also use day name abbreviations: "0 9 * * MON-FRI".
Yes, but be aware of how your cron implementation handles this. In standard Unix cron, if both day-of-month and day-of-week are specified (not *), the job runs when EITHER condition is met (OR logic). For example, "0 0 15 * 5" runs at midnight on the 15th of every month AND every Friday. Some other implementations use AND logic instead.
Absolutely. This tool runs 100% in your browser using client-side JavaScript. No data is sent to any server. Your cron expressions and results never leave your device.
Traditional Unix cron uses the system's local timezone. The next run times shown by this tool use your browser's local timezone. In cloud environments, the timezone depends on the service: AWS CloudWatch uses UTC, Google Cloud Scheduler lets you specify a timezone, and Kubernetes CronJobs default to the kube-controller-manager's timezone.
Standard cron's smallest unit is one minute, so you cannot directly schedule a job every 30 seconds. A common workaround is to create two cron entries: one that runs every minute, and another that runs every minute with a 30-second sleep: "* * * * * /path/to/script.sh" and "* * * * * sleep 30 && /path/to/script.sh". For sub-minute scheduling, consider using systemd timers or a dedicated task scheduler.