cron icon indicating copy to clipboard operation
cron copied to clipboard

Could it be the numerical values for day of week are off by one?

Open Thorongil80 opened this issue 3 years ago • 3 comments

Hi,

I use job_scheduler https://docs.rs/job_scheduler/latest/job_scheduler/ which apparently pulls cron 0.6.1 as dependency.

I noticed that this expression

0 0 17 * * Mon-Sat

is not

0 0 17 * * 1-6

Which according to crontab format however, it should be. The latter expression would fire on Sundays till Friday.

Are you one off in the numerical format for day-of-week?

Or were you one off back then with 0.6.1?

Should I ask job_scheduler to bump to newer version? I opened an issue with them https://github.com/lholden/job_scheduler/issues/29

Best Regards, Thomas

Thorongil80 avatar Nov 28 '22 18:11 Thorongil80

This crate isn't crontab compatible. For one, this crate supports seconds, which crontab doesn't allow at all. Looking at the code, it uses 1 for Sunday, and 7 for Saturday. https://github.com/zslayton/cron/blob/9d54fb7d1c1679136d92f411a7403b774a92d56b/src/time_unit/days_of_week.rs#L32-L38

There is nothing other crates can do which implement this crate besides trying to catch the format and change it manually. But that will only lead into issues with people already using this format.

BlackDex avatar Jan 11 '23 13:01 BlackDex

are there plans to add some sort of chrontab support?

makerio90 avatar Feb 06 '23 03:02 makerio90

Please see this issue. This crate was coded against the Quartz scheduling engine's cron syntax specification. Unfortunately, there is no single definitive standard.

I'm open to supporting various standards via a builder/config API, but I don't have the bandwidth to work on this crate actively.

zslayton avatar Feb 08 '23 19:02 zslayton