[solved] Cron Job doesn't Trigger

Hello,
my openHab system has been running fine for a long time. But now I wanted to add some features. Doing that I’ve noticed that openHab 3 has been released. Migrating to the current version will be a project for next winter. But for now I hope there’s still support for openHab 2.

I’ve added a rule with a cron trigger. But for some reason it doesn’t trigger. The simplified rule looks like that:

rule "systeminfo_cpu_frequency"
    when
        Time cron "0/15 0 0 ? * * *"
//        Item   nCpuTemperature changed
    then
        logInfo("System Rules","CPU FREQ begin")
        //var cpuFreq = executeCommandLine("/opt/openhab2/conf/scripts/cpuFreq.sh", 1000)
        //logInfo("System Rules","CPU freq is: {}", cpuFreq)
        //nCpuFrequency.postUpdate(Float::parseFloat(String::format("%s",cpuFreq)))
        logInfo("System Rules","CPU FREQ end")
end

Using the item trigger nCpuTemperature the rule is triggered. But when using Time cron nothing happens. The rule should trigger every 15 seconds. There is no warning or error in the log files.

How can I check if Quartz is active at all? Do I need to install a binding?

Any help is greatly appreciated!

Thanks a lot.

  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: Buster
    • Java Runtime Environment: Zulu 1.8.0_302
    • openHAB version: 2.5.12

Cron doesn’t support seconds, shortest interval is one minute as far as I now.

Your rule only triggers four times a day:
00:00:00
00:00:15
00:00:30
00:00:45

If you want to trigger each and every 15 seconds, your cron rule should be “0/15 * * ? * * *”

2 Likes

Good morning,

As suggested I was using
https://www.freeformatter.com/cron-expression-generator-quartz.html
because I’m not familiar with the syntax. But apparently I still got it wrong.

Thanks to Chiuaua79 the mystery got solved.

The previous expression in fact triggers only a few times after midnight which I could confirm looking at the log files.
But with 0/15 * * ? * * * the rule is executed every 15 seconds.

Thanks a lot for your support!

Cheers

I OH3 you can build a cron and it tells you what it will do.

  1. Create a new rule
  2. Under WHEN clicktime event
  3. on a schedule (cron) should be selected
  4. Click on the build red icon.

As you change the settings the text in the heading shows you what the cron is doing.
image

image

1 Like