Live data from Hacker News

Show HN: Cronexpr, a Rust library to parse and iter crontab expression

docs.rs

11–20 of 36 posts

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#12

I've LLM based crontab bot. Where I simply write stuff like "run my backupBitBuckettoDropbox.sh from home directory at 3am everyday". I never really liked cronjob expressions.

This sounds great, if i could trust it to get it right 100% of the time.

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#13
post #12

I've LLM based crontab bot. Where I simply write stuff like "run my backupBitBuckettoDropbox.sh from home directory at 3am everyday". I never really liked cronjob expressions.

This sounds great, if i could trust it to get it right 100% of the time.

With the right harness around it you could trust it. Set it up so that it takes your input, generates the cron expression, then uses a deterministic cron library to spit out a summary of what that expression does plus a list of next upcoming instances.

That should give you all the information you need to determine if it got the right expression.

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#14
If 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_job(myfunc, CronTrigger(second='*/15'), id='readout_job')
  scheduler.start()
You can also modify the interval on-the-fly.

[0] https://apscheduler.readthedocs.io/en/3.x/modules/triggers/c...

[1] https://apscheduler.readthedocs.io/en/3.x/modules/executors/...

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#15
post #6

Main drawback is the need for timestamps. Most crontab files or expressions I've seen didn't have them.

Could you elaborate a bit on the issue? I'm not sure you are commenting on cronexpr or other libraries. In cronexpr, there is no requirement for a timestamp until you'd like to find the next scheduled time, and thus you need to provide a related point. To decouple with certain datetime lib, I made a `MakeTimestamp` struct which provides multiple constructors. Later, I found it somehow like a function overload :D

[deleted]

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#16
post #8

Main 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...

Is `timezone` optional? I like it that it has the ability for one to provide it, but not providing it could just use the one the system has been configured to use.

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#17
post #16
post #8

Earlier 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...

Is `timezone` optional? I like it that it has the ability for one to provide it, but not providing it could just use the one the system has been configured to use.

Yeah. Actually, this is possible to extend the interface with options to accept

1. Optional Timezone.

2. Second-level precision (perhaps feature flags are more suitable here)

It just falls out my first requirements so I don't support it. Being too generic is a common source of failure in my experience.

As a library developer I have my opinion on how things should be done and provide the default fits that mind :D

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#19
post #18

After 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?

Re: Show HN: Cronexpr, a Rust library to parse and iter crontab expression

#20
post #14

If 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…

[deleted]
Post reply on HN