croniter icon indicating copy to clipboard operation
croniter copied to clipboard

Support for year in Croniter

Open pattu777 opened this issue 8 years ago • 6 comments

I want to execute a job at 6 AM on 2nd, Feb 2018 only once. The corresponding cron expression would be "0 6 2 2 * 0 2018".

In croniter, seconds is the 6th part of the cron expression. But I am getting CroniterBadError when I try to provide year also. Is there any way to accomplish this. Or this might be a new feature request.

pattu777 avatar Jan 04 '17 05:01 pattu777

+1

m0nzderr avatar Aug 27 '17 00:08 m0nzderr

No, seconds is not the 6th part. Cf https://en.wikipedia.org/wiki/Cron#Overview

kiorky avatar Aug 31 '17 07:08 kiorky

Hang on, why is this closed..

First of all:

base = datetime(2010, 1, 25, 4, 46)
iter = croniter('* * * * * */5', base)
print(iter.get_next(datetime))
print(iter.get_next(datetime))
print(iter.get_next(datetime))

Prints:

2010-01-25 04:46:05
2010-01-25 04:46:10
2010-01-25 04:46:15

Sure looks like the 6th element is seconds to me. If it isn't, please clarify..

And also I'm confused why the year request was just disregarded if there are seconds. Then again, if seconds support is a bug... (which I rely on btw).

holljen avatar Sep 27 '17 12:09 holljen

Even I'm not sure why this was closed. Standard cron doesn't take year into account. So I thought it would be a new feature request.

Apart from that you're correct. This library treats the sixth field of a cron pattern as second.

pattu777 avatar Sep 28 '17 07:09 pattu777

Docs: http://www.nncron.ru/help/EN/working/cron-format.htm

  • Sixth Place should be optional for YEAR

  • Currently the sixth place is for Seconds

omkar-dsd avatar Aug 09 '19 12:08 omkar-dsd

croniter mostly sticks with the original 5fields cron format with some variations.

There are some bits with 6fields (seconds): https://github.com/taichino/croniter#about-second-repeats but not a full support.

PR are welcomes ;-)

kiorky avatar Oct 08 '21 16:10 kiorky