December 20, 2017, 8:09am
Hi, please can someone tell me, why i get an error for this rule?
I want to run the rule every 1st on every month one minute after midnight:
rule "CRON-Rule every 1st on every month"
Time cron "0 1 0 1 * *"
[ERROR] [e.internal.engine.RuleTriggerManager] - Cannot create timer for rule 'CRON-Rule every 1st on every month': CronExpression '0 1 0 1 * *' is invalid.
Could this be because of the last “*”? Should there be a “?” ??? I thought, ? and * is the same in a cron ?
December 20, 2017, 8:44am
I use d the cron maker from the docs and got this:
0 1 0 1 1/1 ? *
December 20, 2017, 9:48am
Hm, i changed mine to “0 1 0 1 * ?” and the error was gone.
Why 1/1 for the month? I think * would be ok?
On the other places i use * or ? without /1 ?
I saw, your cron has 7 places, i have only 6.
0 1 0 1 * ?
seconds --- minutes --- hours --- day --- month --- day of week
What is your additional 7th place?
December 20, 2017, 10:02am
Did you even try to read the
documents? A lot of people spent their time to write those!
December 20, 2017, 10:06am
I have searched the web for cron and there i often saw cron-jobs with only 5 fields (without seconds). But never saw 7 fields…
But you are right, i haven´t looked into openhab docs, only google search…
Is the 7-digits cron job with 1/1 in month-field the same as my cron-job with * in month-field? Are both versions working the same?
Openhab Documentation gives me this link for further explanations:
But with this information, the rule above
0 1 0 1 1/1 ? *
Would be wrong?
Month is from 0 to 11, so it has to be 0/1 or only /1 ?
And why isn´t * for the “day of week”-field not working, only “?” ? It is described, that i can use both? I don´t understand the difference and the explanation.
December 20, 2017, 11:49am
I don’t write cron expressions very often. So, whenever I did, I got frustrated battling the syntax. I find that it’s quicker to use this tool than it is to read the docs, or debug my cron expression. Hope it helps.
December 20, 2017, 11:56am
This is right, but i would like to understand what i´m doing or what my rules do.
January 6, 2018, 5:53pm
Using cron job generator like
https://www.crontab-generator.org/ should guide you set cron job correctly.