NEWS
cronjobs constantly not being executed on time
-
I have several cron timers in my scripts. They are all out of time.
The odd thing is: the delay is always different for every job but constant every day. That means the timers delay differs for every cronjob, sometimes a few minutes, sometimes half an hour. But the difference doesn't change from day to day. It stays that way.
System time of the Raspberry is always correct. CPU load is no problem at all.Timers are supposed to start at the full hour, here is how it looks:
javascript.1 2021-10-20 14:08:04.479 info script.js.common.TestTimer: test on14:08:04
javascript.12021-10-20 13:01:01.529 info script.js.common.TestTimer: test on13:01:01
javascript.1 2021-10-20 12:07:35.291 info script.js.common.TestTimer: test on12:07:35
javascript.1 2021-10-20 11:04:11.698 info script.js.common.TestTimer: test on11:04:11
javascript.1 2021-10-20 10:29:30.745 info script.js.common.TestTimer: test on10:29:30 -
Maybe the systemtime is running out of sync.
The Raspberry is lacking a hardware clock, maybe you want to add one.
These things cost few euros. -
ok, is there way to examine and proove this theory. Because every time I check system time it is correct.
It also wouldn't explain that time differences are so diffently, right? -
Timekeeping on a Raspberry is a thing of it's own...
AFAIK systemd takes care of it and when a difference is recognized the process will try to get in sync by shortening or expanding the duration of a second until it reaches synchronity. But this fails / will take ages when the load on the system is high, further dragging the time out of sync.
You also can try to revert time sync back to the classic system. But this is best executed in connection with a real hardware clock.
-
But: During testing this issue I checked system time immediately after the cronjob was executed (late) and system time was fine. So there is definetly a difference between 'iobroker measures time' and what system time really is.
Also: Time differences wouldn't be the same every day.But certainly there is also the question of how would the OS handle it. In my case I use DietPi and DietPi offers different methods of timesyncd doing its job. Some of them are not very reliable as I know from experince. If only executed daily or even hourly it would lead to inaccuracies.
I have chosen to run it as deamon and dynamic adjustments which seems to work best.I just don't know how to handle this, because like this iobroker without working timers is just useless to me.
-
I have no experience with DietPi so I don't know how this topic is being handled by this distro.
Not that I would know how it exactly is done on Raspberry OS... -
@thomas-braun
It is basically not very much different than any other Linux system.Here as an example:
I made sure that system time is correct shortly befor 14:00h:
systemctl start systemd-timesyncd
checked time with 'date'
Tue Nov 2 13:52:29 CET 2021Then waited for the 14:00h Timertest cronjob, which lead to the following result:
javascript.1 2021-11-02 14:02:32.901 script.js.common.test: TimerTest 14:02:32since then:
15:07:19
16:02:15
17:07:45Systemtime absolutly on spot.
So now I am still looking into iobroker, nodejs ...
My thinking is that the cron implementaion of nodejs is not very reliable, heard about other issues too. Maybe restarting the iobroker.service every day might help.
any enlightenment would be appreciated -
@thomas-braun
Hi Thomas,
can you think of anyone in the team who is familiar with the topic and has the knowledge to examine this issue.
Because I think this is an iobroker/nodejs issue not a Raspberry one.
I'd rather first try to solve this problem before switching to another project.I should add another discovery. If I re-save my script shortly before the time is due, it would be on time.