Cron Expression Sintaxis
Five-campo cron expression campos, special caracteres, y scheduling semantics.
Fields
A standard cron expression has five fields separated by spaces: minute, hour, day of month, month, and day of week. Each field accepts a single value, a range, a list, a step value, or the wildcard asterisk. Fields are evaluated as an AND condition, so all field constraints must match for the job to run. The day-of-month and day-of-week fields have a special OR relationship when both are specified, which is a common source of confusion.
- minute
- 0-59, minute of the hour
- hour
- 0-23, hour of the day
- day of month
- 1-31, day of the month
- month
- 1-12 or names, month of the year
- day of week
- 0-6 or names, Sunday to Saturday
*/5 every 5 min 9 at 9 AM 1 on the 1st JAN for January MON for Monday Special Characters
The asterisk matches all values in the field range. The slash defines a step value, so */5 in the minute field means every five minutes. The hyphen defines an inclusive range, and the comma lists individual values. Some cron implementations support additional macros like @daily, @weekly, and @reboot for common schedules. The question mark is used in Quartz-style cron to omit a day field, but standard cron does not support it.
Common Pitfalls
Specifying both day of month and day of week with non-wildcard values uses OR semantics, meaning the job runs on either matching day, which often surprises users expecting AND. Cron does not guarantee sub-minute resolution, so jobs needing finer granularity require alternative schedulers. Environment variables in cron jobs are minimal, so scripts should set their own PATH. Long-running jobs can overlap if the next trigger fires before completion, so locking is recommended for non-idempotent tasks.