How Cron Expressions Work: Syntax, Examples, and Common Pitfalls
Cron is a Unix-based job scheduler whose five-field syntax — covering minute, hour, day-of-month, month, and day-of-week — is now widely used in CI pipelines, cloud schedulers, and job queues. Each field supports special characters such as wildcards, ranges, lists, and steps, allowing expressions like '0 9 * * 1-5' to schedule a job at 9 AM on weekdays. A key pitfall is time zone handling: cron runs in the time zone of the host machine or service, which often defaults to UTC, potentially causing jobs to fire at unintended local times. In classic Vixie cron, restricting both the day-of-month and day-of-week fields triggers the job when either condition matches, not both — a behaviour that can catch developers off guard. Some schedulers such as Quartz and AWS EventBridge extend the standard five-field format with seconds or year fields, so users should always verify which dialect their tool expects before deploying.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in