croniter
croniter copied to clipboard
Support for year in Croniter
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.
+1
No, seconds is not the 6th part. Cf https://en.wikipedia.org/wiki/Cron#Overview
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).
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.
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
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 ;-)