Get the latest tech news
Show HN: Cronexpr, a Rust library to parse and iter crontab expression
`cronexpr` is a library to parse and drive the crontab expression.
Note that frequencies in general cannot be expressed; only step values which evenly divide their range express accurate frequencies (for minutes and seconds, that’s/2,/3,/4,/5,/6,/10,/12,/15,/20 and/30 because 60 is evenly divisible by those numbers; for hours, that’s/2,/3,/4,/6,/8 and/12); all other possible “steps” and all other fields yield inconsistent “short” periods at the end of the time-unit before it “resets” to the next minute, hour, or day; for example, entering*/5 for the day field sometimes executes after 1, 2, or 3 days, depending on the month and leap year; this is because cron is stateless (it does not remember the time of the last execution nor count the difference between it and now, required for accurate frequency counting—instead, cron is a mere pattern-matcher). By using an asterisk with a step value for day-of-month or day-of-week we put cron into the intersect mode producing unexpected results. The original purpose of this crate to provide a library to parse and drive the crontab expression to find the next timestamp, while the execution part is scheduled outside.
Or read this on Hacker News