lholden / job_scheduler

A simple cron-like job scheduling library for Rust.
Apache License 2.0
196 stars 34 forks source link

Is time absolute or relative to scheduler start? / When will a job run the first time? #10

Closed Boscop closed 4 years ago

Boscop commented 5 years ago

Is time absolute or relative to scheduler start? IOW, is the first time that an added job is run immediately when the scheduler starts, or the next absolute time? E.g. if I add this job to run every 5 minutes, will it run the first time when the minute part of the UTC time is a multiple of 5 after this (e.g. if I add the job at 14:04, will it run at 14:05?), or will it run first 5 minutes from the time when I add the job to the scheduler, or will it run immediately and then every 5 minutes from when I added it?

jordanmack commented 4 years ago

The schedule runs at absolute times, just like cron. It doesn't care when you start it.

0 0/5 * = 14:00, 14:05, 14:10, etc.

You can also do offsets.

0 1/5 * = 14:01, 14:06, 14:11, etc.