[SOLVED] Cron job failing to execute on OH 2.4

  • Platform information:
    • Hardware: Raspberry Pi 3B+
    • OS: openHabian
    • openHAB version: 2.4 Stable

Dear Community!

I have some devices which data needs to be polled and there is no binding available for it. So I’m using Python scripts (and for some, pure HTTP API calls) to poll the data. However it stops executing after some time. Yes I need to use some sleeps and interval during the execution, because it needs some time for execution.

I have found some similar topics, but no real solution. Like remove all sleeps and intervals (which won’t help for me, because then the whole rule is pointless) or to increase cron job thread size. Mainly this is 2 cron job which needs to be polled and I have 1-2 other rule which uses some cron much less often.

What would be the best idea? Using exec binding might help?

Use your python scripts standalone, just publish the results to mqtt. Connect openhab to mqtt to access the results.

Thanks, this could be a workaround. However it requires a bigger rewrite of my scripts…

Any error in the log file? Enable cron debug logging too. Check other threads by me to see how. On the phone traveling so struggling to find it.

Thanks! I have enabled debug logging for quartz.core, I can see some INFO log when refreshing a rule model, but nothing else… I will see your other threads

Is cron still running? Might be best to bounce the openhab service.

Look in the logs after it fails for “interrupted exception” I’m still struggling with that and it cripples anything that resembles “smart home” :frowning:

Thanks I’ll look into. I didn’t have that much time to check this but when I enabled it, I couldn’t see any info regarding cron (I was watching it for almost 20 mins, cron jobs have to happen every 4-5 mins…), not even an error… but when I refreshed the rule, there were some debug log regarding cron so I think it is still running.

Mine takes anywhere from a day to a week to totally crash :frowning:

I wouldn’t say this is normal… I knew that default only 2 cron jobs allowed pararell, but I have increased it and I never thought that if I have more jobs, that will mean that the whole cron core will fail…

I could ‘t even restart cron bundle just with a complete restart…
Which OH version do you use?

Yup, only a restart solves it. :frowning:

I’m on 2.4.

Same for me. Is there an issue created about this in GitHub? If not I’ll make one, hope someday someone will check it…

Did you tried exec binding? I wanted to them with it first but somewhere I stuck that’s why I stepped back. But other commands running with exec binding is working fine even after this cron is down… you can achieve almost the same functionality but you dont have to deal with cron triggers

If you can give a way to recreate it, open an issue. I think it’s a probl with cron, not OH.

Do you see the “interrupted exception” in your logs?

No I can’t see any error related to cron :slight_smile: But I’m sure that debug is enabled because when I refreshed rule files I could see some DEBUG logs…

I’ll try what I said. Move this scripts to be executed by the exec binding. This is the easiest way I think, needs little changes. I will document here my achievements…

Now I have restarted my openHab, I can see the cron debug logs… So that means for me, when it stops, it stops completely, like it is stuck in a deadlock…

It would be interesting to see if you get the “interrupted exception” in your logs. I think you need trace on to see them though.

If I set my cron thread count to 5, I’ll eventually see 5 errors and then it stops. 2, 2 errors and it stops. It’s like cron is dieing underneath.

It seems that for me after it stops, it doesn’t show any error (also no errors when it stops…).

I have moved one of my scripts to the exec binding and the trigger is now the output channel of the exec binding. It works much better…

Also on 2.5 Milestone builds these problems seems to be gone