Loading ...
Sorry, an error occurred while loading the content.

Time Zone issues and Clock Setting on Linux

Expand Messages
  • Victor Emmanuel
    Hi Guys, I have a Centos Box that my IP-Phones sync to as their timeserver  but often the time displayed on these phones are always one hour ahead of my local
    Message 1 of 5 , May 27, 2011
    • 0 Attachment
      Hi Guys,

      I have a Centos Box that my IP-Phones sync to as their timeserver  but often the time displayed on these phones are always one hour ahead of my local time so I had to check the system (the centos box) to see what was wrong. On the IP-Phone web interface I have the set the following as options:

      SNTP: <ipaddress of my Centos Box>

      GMT Offset: <+1> ; I have selected +1 from the drop down menu.

      I ran the following command "date", "clock" ,"time"and got different responses as shown below:

      [root@CENTRIX5500 ~]# time

      real    0m0.000s
      user    0m0.000s
      sys     0m0.000s

      [root@CENTRIX5500 ~]# date

      Fri May 27 13:52:28 WAT 2011

      [root@CENTRIX5500 ~]# clock

      Fri 27 May 2011 02:52:34 PM WAT  -0.760654 seconds

      [root@CENTRIX5500 ~]#


      Normally when I was installing the system I specified my timezone which was GMT +1 i.e GMT 1200 is 1300 in my time and that was the only question that was related to time that the OS asked me during installation and nothing more.

      Though I must say I really don't know the differences in the various
      commands I used above but :

      1. Why these differences in value especially between
      "date" and "clock" and what does each command stands for?

      2. If it is abnormal, how do I correct it?

      3. What can I do to make sure that the phone syncs properly and get the real time value?

      4. Do I need to run NTP services on my server to be able to sync accurately?

      5. If I need to set time accurate on my system which of the command is appropriate and how do I set the time zone with these commands

      6. There is always this UTC and GMT issues on time setting. Which is the best and what exactly are the differences between these two?


      Thanks.

      Regards,

      EV.

      --

      Christ in me the hope of Glory!


      [Non-text portions of this message have been removed]
    • Michael Kjorling
      ... Hash: SHA1 ... Usually when you install Linux you will be asked whether your system real-time clock (RTC or BIOS clock) is set to local time or GMT. If you
      Message 2 of 5 , May 27, 2011
      • 0 Attachment
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        On May 27 2011 06:33 -0700, from clickvictor@... (Victor Emmanuel):
        > Normally when I was installing the system I specified my timezone
        > which was GMT +1 i.e GMT 1200 is 1300 in my time and that was the
        > only question that was related to time that the OS asked me during
        > installation and nothing more.

        Usually when you install Linux you will be asked whether your system
        real-time clock (RTC or BIOS clock) is set to local time or GMT. If
        you answer this incorrectly, the system time will be off accordingly.

        Surely this can be changed after the installation as well, but as I
        always keep the RTC set to UTC time and only do time-zone adjustments
        in the OS, I'm not sure of the exact steps, particularly on CentOS.


        > 1. Why these differences in value especially between
        > "date" and "clock" and what does each command stands for?

        man date
        man clock

        > 2. If it is abnormal, how do I correct it?

        The first few lines of the man pages should guide you.


        > 4. Do I need to run NTP services on my server to be able to sync
        > accurately?

        If you want your phones to sync to that server, then you will need to
        run something they can sync to. NTP is likely by far the most commonly
        used protocol for time synchronization over the network.

        You will also need an accurate system time on the server (so the
        clients get the correct time) but that does not have to imply NTP. Any
        high-quality time source is as good as any other, but running NTP is
        easier and cheaper than buying and hooking up your own atomic clock.
        In principle, you could as easily use GPS as a time source - I'm
        willing to bet there is readily available software for this.


        > 5. If I need to set time accurate on my system which of the command
        > is appropriate and how do I set the time zone with these commands

        To set the time zone for display purposes, set the TZ environment
        variable. I strongly suggest you leave the system clock and RTC set to
        UTC.

        To set the system's local time zone for all users, look at
        /etc/localtime.


        > 6. There is always this UTC and GMT issues on time setting. Which is
        > the best and what exactly are the differences between these two?

        For all practical purposes, for laypeople they are the same. Don't
        worry about this part unless you need sub-second accuracy.

        http://en.wikipedia.org/wiki/Coordinated_Universal_Time#Relationship_to_other_standards

        - --
        Michael Kjörling .. michael@... .. http://michael.kjorling.se
        * ..... No bird soars too high if he soars with his own wings ..... *
        * ENCRYPTED email preferred -- OpenPGP keys: 0x32D6B8C6, 0xBDE9ADA6 *
        * ASCII Ribbon Campaign: Against HTML mail, proprietary attachments *

        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.10 (GNU/Linux)

        iD8DBQFN36zgdY+HSb3praYRAhGRAJ92xtid1lCTjeYSX+/PRXwh7AABngCgi7nR
        UeUYvuHzFR3gvSULyNJx+pk=
        =xwld
        -----END PGP SIGNATURE-----
      • Scott
        ... Edit /etc/adjtime Then, run ntpdate to put it into sync. If running ntpd you ll have to briefly stop it. Then just something like ntpdate pool.ntp.org
        Message 3 of 5 , May 27, 2011
        • 0 Attachment
          On Fri, May 27, 2011 at 01:53:36PM +0000, Michael Kjorling wrote:
          > -----BEGIN PGP SIGNED MESSAGE-----
          > Hash: SHA1
          >
          > On May 27 2011 06:33 -0700, from clickvictor@... (Victor Emmanuel):
          >
          > Usually when you install Linux you will be asked whether your system
          > real-time clock (RTC or BIOS clock) is set to local time or GMT. If
          > you answer this incorrectly, the system time will be off accordingly.



          >
          > Surely this can be changed after the installation as well, but as I
          > always keep the RTC set to UTC time and only do time-zone adjustments
          > in the OS, I'm not sure of the exact steps, particularly on CentOS.

          Edit /etc/adjtime

          Then, run ntpdate to put it into sync. If running ntpd you'll have to
          briefly stop it. Then just something like ntpdate pool.ntp.org should
          put time in sync. I forgot the preconfigured options in the startup
          script, so not sure if ntpd syncs at start or not. So, the sequence
          after editing /etc/adjtime


          service ntpd stop
          ntpdate pool.ntp.org
          service ntpd start

          (Or go through the startup ntpd script to see if it syncs at boot, but
          the three commands above take less time.)

          Victor, please trim messages. See the posting rules on the list's home
          page. We appreciate that you're not top posting, but putting 70-100
          lines of a previous message also makes it hard to follow.


          --
          Scott Robbins
          PGP keyID EB3467D6
          ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
          gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

          Anya: Listen, I have this little project I'm working on, and I
          heard you were the person to ask if...
          Willow: Yeah, that's me. Reliable dog-geyser-person.
        • thad_floryan
          ... Correct! I was the owner/operator of the free BATS (Bay Area Time Service) system for a long time; it had a large outdoor dipole antenna feeding a
          Message 4 of 5 , Jun 1, 2011
          • 0 Attachment
            --- In linux@yahoogroups.com, Michael Kjorling <michael@...> wrote:
            > [...]
            > If you want your phones to sync to that server, then you will need to
            > run something they can sync to. NTP is likely by far the most commonly
            > used protocol for time synchronization over the network.
            >
            > You will also need an accurate system time on the server (so the
            > clients get the correct time) but that does not have to imply NTP. Any
            > high-quality time source is as good as any other, but running NTP is
            > easier and cheaper than buying and hooking up your own atomic clock.
            > In principle, you could as easily use GPS as a time source - I'm
            > willing to bet there is readily available software for this.

            Correct! I was the owner/operator of the free BATS (Bay Area Time
            Service) system for a long time; it had a large outdoor dipole
            antenna feeding a Heathkit NBS (now NIST) "atomic" clock using the
            time signals from Fort Collins CO and that was fed into (RS-232) one
            of my UNIX boxes running 24/7/365 that had multiple phone lines that
            people could call to sync their system's time using a number of
            different protocols. It all worked fine until 17-OCT-1989 when the
            Loma Prieta earthquake hit shortly after 5pm local time. The ground
            shaking stressed the dipole antenna mountings and it came down. I
            quickly put up a replacement antenna which can be seen in this pic
            (first thumbnail; click on it):

            <http://thadlabs.com/PIX/LX200/>

            After a while, I said the "to heck with it". NTP was becoming almost
            ubiquitous then (1989) and I repurposed the phone lines to FAX, etc.
            and later (2002) abandoned landlines and went cellphone only.

            > [...]
            > > 5. If I need to set time accurate on my system which of the command
            > > is appropriate and how do I set the time zone with these commands
            >
            > To set the time zone for display purposes, set the TZ environment
            > variable. I strongly suggest you leave the system clock and RTC set to
            > UTC.
            >
            > To set the system's local time zone for all users, look at
            > /etc/localtime.

            Or one can simply ntpdate. I debated ntp on my Sheevaplugs since they
            are up 24/7/365, but it was simpler to cron this daily:

            /usr/sbin/ntpdate ntp.ubuntu.com

            which is "good enough" because the Plugs' clocks don't drift all that
            much -- less than one second a day. Interestingly, my Windows boxes
            do use ntp by default.
          • Victor Emmanuel
            ... From: thad_floryan Subject: [linux] Re: Time Zone issues and Clock Setting on Linux To: linux@yahoogroups.com Date: Wednesday, June 1,
            Message 5 of 5 , Jun 4, 2011
            • 0 Attachment
              --- On Wed, 6/1/11, thad_floryan <thad@...> wrote:

              From: thad_floryan <thad@...>
              Subject: [linux] Re: Time Zone issues and Clock Setting on Linux
              To: linux@yahoogroups.com
              Date: Wednesday, June 1, 2011, 8:57 PM







               









              --- In linux@yahoogroups.com, Michael Kjorling <michael@...> wrote:

              > [...]

              > If you want your phones to sync to that server, then you will need to

              > run something they can sync to. NTP is likely by far the most commonly

              > used protocol for time synchronization over the network.

              >

              > You will also need an accurate system time on the server (so the

              > clients get the correct time) but that does not have to imply NTP. Any

              > high-quality time source is as good as any other, but running NTP is

              > easier and cheaper than buying and hooking up your own atomic clock.

              > In principle, you could as easily use GPS as a time source - I'm

              > willing to bet there is readily available software for this.



              Correct! I was the owner/operator of the free BATS (Bay Area Time

              Service) system for a long time; it had a large outdoor dipole

              antenna feeding a Heathkit NBS (now NIST) "atomic" clock using the

              time signals from Fort Collins CO and that was fed into (RS-232) one

              of my UNIX boxes running 24/7/365 that had multiple phone lines that

              people could call to sync their system's time using a number of

              different protocols. It all worked fine until 17-OCT-1989 when the

              Loma Prieta earthquake hit shortly after 5pm local time. The ground

              shaking stressed the dipole antenna mountings and it came down. I

              quickly put up a replacement antenna which can be seen in this pic

              (first thumbnail; click on it):



              <http://thadlabs.com/PIX/LX200/>



              After a while, I said the "to heck with it". NTP was becoming almost

              ubiquitous then (1989) and I repurposed the phone lines to FAX, etc.

              and later (2002) abandoned landlines and went cellphone only.



              > [...]

              > > 5. If I need to set time accurate on my system which of the command

              > > is appropriate and how do I set the time zone with these commands

              >

              > To set the time zone for display purposes, set the TZ environment

              > variable. I strongly suggest you leave the system clock and RTC set to

              > UTC.

              >

              > To set the system's local time zone for all users, look at

              > /etc/localtime.



              Or one can simply ntpdate. I debated ntp on my Sheevaplugs since they

              are up 24/7/365, but it was simpler to cron this daily:



              /usr/sbin/ntpdate ntp.ubuntu.com



              which is "good enough" because the Plugs' clocks don't drift all that

              much -- less than one second a day. Interestingly, my Windows boxes

              do use ntp by default.
              >
              >
              Thanks Thad, Scott and Michael for your contribution.

              Will do just that.

              Regards,

              Victor.


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.