Looks well done. I like how the docs describe every syntax feature, and every non-standard feature in detail. Hat tip to implementing Vixie's "*,10" quirk, and to handling DST.
You're welcome! As described in the "Why do you create this crate?" section, I actually started this domain only a few weeks ago. So I experienced how those tribal rules can be confusing and hard to search over the Internet the understand their semantic. And when I sorted out the parse structure [1] and finished the extensions [2][3], I believe I should write it down for others (and future me) :D [1] https://github.c…
Show HN: Cronexpr, a Rust library to parse and iter crontab expression
21–30 of 36 posts
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#22Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#23After working with Jenkins which has "hashed value" support for automatic staggering of jobs, I think its essential in any cron syntax evaluater.
This can be optionally supported. To be clear, does it mean almost "RANDOM at construction" and the parser will assign a value by a hash/random function and then the crontab struct has an immutable value of that field?
For an API, I could see either taking in something that is hashable or just taking in a number and letting the caller choose their hashing. From the person's perspective writing cron syntax, they shouldn't care so long as they get the intended affect.
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#24Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#25isn't cron removed from most distros? now you need 3 or 4 different files for systemd-cronie
I think you're confusing systemd timer units with Cronie[0], a crond implementation that I think predates systemd? It's possible there's some systemd thing I don't know about though!
I think most distros at least have an installable crond
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#26Earlier quoted context omitted.
If you mean timezone, I wrote an FAQ [1]: "Why does the crate require the timezone to be specified in the crontab expression?" [1] https://docs.rs/cronexpr/latest/cronexpr/#why-does-the-crate...
So many of these restrictions feels arbitrary. Not supporting comments? Why? Assuming UTC for tz is not weird and cron users expect it, I guess why even support this specific syntax if the crons need to be edited to fit how this code expects them? There may have been better options if you were going full green field. Good work though!
That would definitely be weird and unexpected. My crons are interpreted with respect to my system's configured time zone, which seems way more expected than just using UTC.
Taking a datetime and just assuming it's UTC is often a mistake. It's why the TC39 Temporal proposal (overhauling datetimes for Javascript) won't let you silently do it.
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#27Earlier quoted context omitted.
So many of these restrictions feels arbitrary. Not supporting comments? Why? Assuming UTC for tz is not weird and cron users expect it, I guess why even support this specific syntax if the crons need to be edited to fit how this code expects them? There may have been better options if you were going full green field. Good work though!
> Assuming UTC for tz is not weird and cron users expect it, That would definitely be weird and unexpected. My crons are interpreted with respect to my system's configured time zone, which seems way more expected than just using UTC. Taking a datetime and just assuming it's UTC is often a mistake. It's why the TC39 Temporal proposal (overhauling datetimes for Javascript) won't let you silently do it.
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#28Main drawback is the need for timestamps. Most crontab files or expressions I've seen didn't have them.
If you mean timezone, I wrote an FAQ [1]: "Why does the crate require the timezone to be specified in the crontab expression?" [1] https://docs.rs/cronexpr/latest/cronexpr/#why-does-the-crate...
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#29If you're into Python, APScheduler is the way to go. It also has a cron scheduler [0] which includes scheduling down to seconds and perfectly integrates with asyncio [1]. async def myfunc(): print(f"\n{Fore.GREEN}Readout triggered at { datetime.now().strftime('%H:%M:%S') }{COLORS_RESET}\n") await disk_temperatures_handler.readout(storage) scheduler = AsyncIOScheduler() storage['scheduler'] = scheduler scheduler.add_j…
Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression
#30isn't cron removed from most distros? now you need 3 or 4 different files for systemd-cronie