
Cron Expressions Are Not Hard, They Are Just Badly Explained
Every developer who has set up a scheduled task has stared at a cron expression and questioned their career choices. 0 */4 * * 1-5 looks like line noise until you understand the five-field structure, and then it becomes one of the most elegant scheduling syntaxes ever designed. The problem is not cron. The problem is that every explanation starts with the syntax instead of the mental model. The mental model A cron expression answers one question: "Which minutes of which hours of which days should this run?" There are five fields, left to right: Minute (0-59): Which minute of the hour Hour (0-23): Which hour of the day Day of month (1-31): Which day of the month Month (1-12): Which month Day of week (0-6, Sunday=0): Which day of the week An asterisk means "every." A number means "only this one." A comma separates multiple values. A hyphen defines a range. A slash defines a step. That is the entire syntax. Everything else is combinations of these rules. Building expressions by example Ev
Continue reading on Dev.to DevOps
Opens in a new tab




