RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Date/Time synchronization

    Scheduled Pinned Locked Moved Help and Support
    boottimesynchronizeraspbian
    12 Posts 2 Posters 2.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JoeCool Banned
      last edited by

      Hi all,

      In my config, I have a service which should log its starting date and time in a log file.
      All is ok but the time is not correct. It seems to be about the last shutdown time + 5 sec.

      I read that the Raspberry doens't have a RTC (Real Time Clock) and that is why, the time is not synchronize at boot. But after few second, the time is correct.

      I'm connected to internet. Does the Rasperry synchronize its time at boot ? and how ?
      Is it just magic ^^ ??

      Thanks for your lights.
      Joe.

      mituM 1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator @JoeCool
        last edited by mitu

        @joecool said in Date/Time synchronization:

        I'm connected to internet. Does the Rasperry synchronize its time at boot ? and how ?

        It uses NTP to synchronize it's date/time using the internet.

        J 1 Reply Last reply Reply Quote 0
        • J
          JoeCool Banned @mitu
          last edited by

          @mitu Ha ? I saw that ntd was not use anymore and maybe timedatectl was used in place.

          mituM 1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator @JoeCool
            last edited by

            @joecool timedatectl is only setting/reading the date, does not speak NTP. You're probably thinking about systemd-timesyncd, but I don't think that's installed in Raspbian.

            J 1 Reply Last reply Reply Quote 0
            • J
              JoeCool Banned @mitu
              last edited by

              @mitu You're probably right. My problem is to know how this sync works. I'm sorry, but there is a blur in my mind about that time sync.

              Concretely, can we list, please, each step (init.d, service, etc...) responsible to the sync time process during the Raspbian start ?

              I will be nice for me ;) !

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @JoeCool
                last edited by

                @joecool said in Date/Time synchronization:

                My problem is to know how this sync works.

                Via NTP (either using ntpd or systemd-timesyncd, both speak the same protocol). I don't have a PI at hand to check, but I think you can check the list of systemd running services and see if ntpd is enabled.

                J 1 Reply Last reply Reply Quote 0
                • J
                  JoeCool Banned @mitu
                  last edited by

                  @mitu yep, only systemd-timesyncd.service is enabled...
                  Could I say to my new service to wait for the launch of systemd-timesyncd.service ?

                  mituM 1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator @JoeCool
                    last edited by

                    @joecool said in Date/Time synchronization:

                    Could I say to my new service to wait for the launch of systemd-timesyncd.service ?

                    Yes.

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      JoeCool Banned @mitu
                      last edited by

                      @mitu Add "After=systemd-timesyncd.service" (in the [Unit] section) into my <blabla>.service file, right ?
                      I will try now...

                      J 1 Reply Last reply Reply Quote 0
                      • J
                        JoeCool Banned @JoeCool
                        last edited by

                        @joecool said in Date/Time synchronization:

                        @mitu Add "After=systemd-timesyncd.service" (in the [Unit] section) into my <blabla>.service file, right ?
                        I will try now...

                        It does not seem to work (with After=...). I tried with systemd-timesyncd.service, time-sync.target and sysinit.targetbut no one works... Strange !!

                        The time is always the last known... that at the moment of the shutdown.

                        I continue to search... If you have any idea, will be cool.

                        1 Reply Last reply Reply Quote 0
                        • mituM
                          mitu Global Moderator
                          last edited by

                          Instead of strictly depending on the timesyncd service, try making your service depending on the network target , otherwise the time service doesn't have a chance to do any synchronisation. Add a delay before the service starts using the ExecStartPre to run sleep for 2-3 seconds.

                          J 1 Reply Last reply Reply Quote 0
                          • J
                            JoeCool Banned @mitu
                            last edited by

                            @mitu said in Date/Time synchronization:

                            epending on the timesyncd service

                            Good idea, I'm going to try that. Thanks.

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

                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.