[SOLVED] Cron trigger - Every 5 minutes works, daily doesn't

  • Platform information:
    • Hardware: ODroid UX4, Arm
    • OS: Ubuntu 16
    • Java Runtime Environment: Azul Zulu embedded 8
    • openHAB version: 2.5 M1

Hi everyone

I’ve setup 4 rules which all work, when triggered via a switch item.

All the rules are supposed to run on a Cron trigger.

The first rule works perfectly, with this line

rule "Accumlate Heating costs every 5 minutes"
	when
		Time cron "0 0/5 * 1/1 * ? *" // change to "0 0/15 * 1/1 * ? *" for every 15 minutes

But the remaining rules don’t seem to be triggering.

(Obviously I haven’t seen the month or year yet, but the daily one certainly isn’t running.)

I’ve double checked the Cron syntax a number of times using cronmaker.com

rule "Daily Cost"
	when
		Time cron "0 1 0 1/1 * ? *" // 1 minute past  Midnight every day

rule "Month Cost"
	when
		Time cron "0 1 0 1 1/1 ? *" // Every 1st of month at 1 minute past Midnight

rule "Year Cost"
	when
		Time cron "0 2 0 1 1 ? *" // Every year on Jan 1st at 2 minutes past midnight

In fact, although the cron syntax is correct, I would prefer a more simple one:

"0 0/5 * * * ?" //every 5 Minutes
  "0 1 0 * * ?" //daily at 12:01 am
  "0 1 0 1 * ?" //monthly at 01 12:01 am
  "0 2 0 1 1 ?" //yearly at 01-01 12:02 am

year is optional, * is “don’t care”, ? is mandatory either on day OR weekday, ? must be set exactly once.
But your definition is fine, I have no idea why it shouldn’t work.

2 Likes

Thanks Udo

I’ll tweak the Cron values as you suggest.

As I was drifting off to sleep last night it stuck me that the Cron trigger might be working perfectly and the rule is being stopped by the next part.

I forgot that I added a single command into each rule, so maybe…

Update

Yes, it turns out the the midnight rule was triggering, but it was failing on the first event.

I’ve commented it out and I’ll work out what’s wrong with that part later.