Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. English
    3. Scripting / Logic
    4. Blockly
    5. cronjobs constantly not being executed on time

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    cronjobs constantly not being executed on time

    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Pausentee last edited by Pausentee

      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

      Thomas Braun 1 Reply Last reply Reply Quote 0
      • Thomas Braun
        Thomas Braun Most Active @Pausentee last edited by

        @pausentee

        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.

        P 1 Reply Last reply Reply Quote 0
        • P
          Pausentee @Thomas Braun last edited by

          @thomas-braun

          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?

          Thomas Braun 1 Reply Last reply Reply Quote 0
          • Thomas Braun
            Thomas Braun Most Active @Pausentee last edited by

            @pausentee

            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.

            P 1 Reply Last reply Reply Quote 0
            • P
              Pausentee @Thomas Braun last edited by Pausentee

              @thomas-braun

              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.

              Thomas Braun 1 Reply Last reply Reply Quote 0
              • Thomas Braun
                Thomas Braun Most Active @Pausentee last edited by

                @pausentee

                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...

                P 2 Replies Last reply Reply Quote 0
                • P
                  Pausentee @Thomas Braun last edited by Pausentee

                  @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 2021

                  Then 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:32

                  since then:
                  15:07:19
                  16:02:15
                  17:07:45

                  Systemtime 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

                  1 Reply Last reply Reply Quote 0
                  • P
                    Pausentee @Thomas Braun last edited by Pausentee

                    @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.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post

                    Support us

                    ioBroker
                    Community Adapters
                    Donate

                    484
                    Online

                    31.9k
                    Users

                    80.2k
                    Topics

                    1.3m
                    Posts

                    2
                    8
                    707
                    Loading More Posts
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes
                    Reply
                    • Reply as topic
                    Log in to reply
                    Community
                    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                    The ioBroker Community 2014-2023
                    logo