Cron expressions schedule commands and scripts in Unix-like operating systems. Each expression specifies when a task should run, such as every minute, every hour, or at a fixed time on selected days. A common example is the cron expression for every 5 minutes, which suits recurring tasks such as health checks, cache refreshes, and periodic data processing.
Standard Unix cron uses five fields: minute, hour, day of month, month, and day of week. Its smallest scheduling interval is one minute. Commands run in the server’s configured time zone unless the cron implementation provides a way to override it. The Cron Expression Builder & Explainer accepts standard five-field expressions in the browser and provides a plain-English explanation and the next five run times in UTC. It does not support Quartz syntax.
Understanding the Cron Format
A cron expression is a string composed of five fields, separated by spaces. Each field represents a specific unit of time:
- Minute (0-59)
- Hour (0-23)
- Day of the Month (1-31)
- Month (1-12)
- Day of the Week (0-6) (Sunday to Saturday)
For example, the cron expression 0 0 * * * runs at midnight every day. But what if you want to run a task every 5 minutes? That’s where the cron expression for every 5 minutes comes into play.
Cron Expression for Every 5 Minutes
To run a task every 5 minutes with standard Unix cron, set the minute field to */5 and use * for the remaining fields:
*/5 * * * *
The fields work as follows:
*/5matches minutes 0, 5, 10, 15, and so on through 55 in every hour.*in the hour field allows the task to run during every hour.*in the day-of-month field allows every day of the month.*in the month field allows every month.*in the day-of-week field allows every day of the week.
Because all four remaining fields are unrestricted, the cron expression for every 5 minutes runs continuously, including at midnight and on the first day of each month. The schedule follows the time zone configured for the cron daemon.
Practical Examples of Using Cron Expressions
A daily report scheduled for 8:00 AM uses the minute, hour, day-of-month, month, and day-of-week fields:
0 8 * * *
To run a script every 5 minutes on weekdays, combine the step operator with a weekday range:
*/5 * * * 1-5
Here, */5 selects minutes 0, 5, 10, and so on through 55, while 1-5 selects Monday through Friday.
To run a task at 9:00 AM and 5:00 PM on weekdays, separate the hours with a comma:
0 9,17 * * 1-5
These examples use standard five-field cron syntax. The Cron Expression Builder & Explainer provides a plain-English interpretation and displays the next five run times in UTC.
Advanced Cron Expressions
Standard Unix cron supports lists, ranges, and step values, but it does not support Quartz-specific operators such as L, W, or #.
In Quartz syntax, L selects the last day of the month. Because Quartz includes a seconds field and requires ? in one day field, midnight on the last day is written as:
0 0 0 L * ?
The W operator selects the weekday nearest to the specified day. For example, this Quartz expression runs at midnight on the weekday nearest the 15th:
0 0 0 15W * ?
Quartz also supports # to select a numbered occurrence of a weekday. In Quartz, 6 represents Friday, so the third Friday of each month is:
0 0 0 ? * 6#3
Quartz expressions cannot be pasted into a standard crontab. Standard crontabs also cannot use the seconds field, ?, L, W, or #.
Troubleshooting Common Cron Issues
Most cron failures come from the environment, path resolution, scheduling semantics, or missing output. Check these areas when a job does not run as expected:
- Environment variables: Cron jobs receive a limited environment. Set required variables explicitly in the crontab or load them from a known file within the command.
- Paths: Use absolute paths for the script, interpreter, working directory, and executable files. A cron job does not reliably inherit the same
PATHas an interactive shell. - Permissions: Confirm that the cron user can read the script and execute its dependencies. The job runs with the permissions of the account that owns the crontab.
- Shell behavior: Put complex commands in a script instead of relying on shell aliases or interactive shell features.
- Logging: Capture standard output and standard error to diagnose failures. For example, use
/path/to/script >> /path/to/job.log 2>&1. - Day-field matching: In standard cron, when both day-of-month and day-of-week are restricted, the job runs when either field matches. Restrict only one field when both should be required.
- Time zone: Cron normally uses the server’s time zone unless the implementation supports a setting such as
CRON_TZ.
The Cron Expression Builder & Explainer checks standard five-field expressions and shows their next five run times in UTC. It does not execute jobs or validate Quartz expressions.
Using cron Expressions Reliably
The cron expression for every 5 minutes is */5 * * * *. It runs at minutes 0, 5, 10, and so on through minute 55 of every hour. More complex expressions can schedule tasks by day, month, or weekday, but the standard five-field format remains the safest choice for Unix crontab files.
Use the Cron Expression Builder & Explainer to enter a standard five-field expression and select Explain. It provides a plain-English reading and the next five run times in UTC. Test expressions against a staging environment and confirm the server’s time zone before deploying them.
Common Uses for Five-Minute Cron Jobs
A five-minute interval suits recurring tasks that need frequent updates but do not require execution every minute. The schedule should match the task’s actual tolerance for delay and the system’s available capacity.
Data synchronization: Schedule a job to transfer new records, refresh an analytics pipeline, or update a monitoring dashboard every five minutes. Add locking or an idempotency check to prevent overlapping runs from processing the same data twice.
Log processing: Run log collection, archival, or analysis tasks on a five-minute schedule. Apply retention limits and monitor disk usage, since a five-minute interval may generate many output files in a busy application.
Health checks and monitoring: Check server availability, application endpoints, queue backlogs, or external service status every five minutes. Include timeouts and concise failure logging so a stalled check does not block the next execution.
Five-minute jobs still require error handling and monitoring. Configure the scheduler to capture output, send failures to an appropriate alert channel, and verify that each command exits cleanly. The same */5 * * * * schedule works across these tasks, while each command remains responsible for its own validation and recovery.
Advanced Techniques for Standard Cron and Quartz
Standard cron supports lists, ranges, and steps, but it does not provide the full scheduling syntax found in Quartz or other nonstandard implementations. Confirm the cron dialect used by the target scheduler before applying an advanced expression.
Combining Multiple Intervals
Use a comma to create an OR condition within a field. For example, */15,30,45 * * * * runs at minutes 0, 15, 30, and 45 of every hour. The */15 step already includes minutes 0, 30, and 60, while the explicit values add minute 45.
Commas combine values inside one field; they do not combine separate cron expressions. To run different expressions, create separate cron entries or schedules.
Restricting Calendar Days
When both day-of-month and day-of-week are restricted, standard cron runs the job when either field matches. This differs from some implementations that require both conditions. Test expressions against the actual scheduler when combining day constraints.
Using Quartz Syntax
Quartz expressions contain six or seven fields: seconds, minutes, hours, day-of-month, month, day-of-week, and an optional year. One of the day fields must use ?. Quartz also supports L, W, and #. For example, 0 0/5 * * * ? runs every five minutes at second 0, while 0 0 12 ? * 6#3 runs at noon on the third Friday of each month.
Quartz expressions cannot be pasted into a standard crontab. The QuikConsole Cron Expression Builder handles standard five-field expressions. Its Explain button provides a plain-English reading and the next five run times in UTC.