LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-04-2011, 12:27 PM   #1
m4rtin
Member
 
Registered: Sep 2007
Posts: 261

Rep: Reputation: 16
ntpdate/ntpd time is in UTC instead of local time?


I live in UTC+3 time-zone. If I execute ntpd or ntpdate, I always get the UTC time instead of UTC+3. For example:

root@ubuntu:/home/ubuntu# ntpdate -q pool.ntp.org
server 193.40.5.113, stratum 2, offset -0.002151, delay 0.04903
server 193.40.133.142, stratum 1, offset -0.002581, delay 0.04958
server 81.20.144.33, stratum 3, offset -0.000056, delay 0.04654
4 May 17:24:46 ntpdate[6816]: adjust time server 193.40.133.142 offset -0.002581 sec
root@ubuntu:/home/ubuntu#

..actually the clock is 20:24. What might cause such issue? If any additional information is required, please ask
 
Old 05-04-2011, 12:45 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
If /etc/localtime is a symbolic link, what is it linked to? If not, what is the output of strings /etc/localtime ? If /etc/localtime does not exist, create it as a symbolic link to your preferred timezone by cd /etc && ln -s /usr/share/zoneinfo/<whatever> localtime where <whatever> is a file under /usr/share/zoneinfo/ or in a subdirectory under it.
 
Old 05-04-2011, 12:52 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,506

Rep: Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114Reputation: 4114
In addition if the time zone information is correct and the output of the date command shows a difference of 3 hours then either your hardware clock is set to UTC and the OS thinks it is local or vice verse.
 
Old 05-04-2011, 12:57 PM   #4
m4rtin
Member
 
Registered: Sep 2007
Posts: 261

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by catkin View Post
If /etc/localtime is a symbolic link, what is it linked to? If not, what is the output of strings /etc/localtime ? If /etc/localtime does not exist, create it as a symbolic link to your preferred timezone by cd /etc && ln -s /usr/share/zoneinfo/<whatever> localtime where <whatever> is a file under /usr/share/zoneinfo/ or in a subdirectory under it.
catkin, thanks a lot! Making a symbolic link to a correct time zone and executing ntpd did the think. Is such configuration general to all distributions or just to Debian-based?
 
Old 05-04-2011, 01:00 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by m4rtin View Post
catkin, thanks a lot! Making a symbolic link to a correct time zone and executing ntpd did the think. Is such configuration general to all distributions or just to Debian-based?
I think it is more general than that; it's the same on Slackware64 13.1 (except it's a copy, not a link so harder to know which timezone has been chosen but functionally the same).
 
Old 05-05-2011, 06:06 PM   #6
m4rtin
Member
 
Registered: Sep 2007
Posts: 261

Original Poster
Rep: Reputation: 16
catkin, I can confirm, that this /etc/localtime technique works on OpenSUSE 11.3 as well

As I understand, there are two clocks in Linux- hardware clock and system time. Hardware clock(battery powered RTC chip on the motherboard) is accessed by hwclock and probably mainly used by Linux during the boot-up process(time-stamp kernel ring buffer messages etc) and setting the system time first time? When Linux is running, the system time should be in use by applications. One can configure the system time to be accurate using NTP servers. What purpose has hardware clock once the Linux is running?
 
Old 05-05-2011, 06:26 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,715

Rep: Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550Reputation: 3550
Linux doesn't use the hardware clock because they have been so crap (historically) and drift too much. Not to mention BIOS batteries dying.
These days it probably should - and on enterprise class equipment this causes problems. Likewise as guests under virtualization.
Work-arounds and hacks are needed when they shouldn't be.

Regardless, a time reference (preferably UTC) is required with local offset where needed. Using a (good) hardware clock would be better than software timer calculations.
 
Old 05-06-2011, 07:57 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Another reason for not using the RTC after boot is that on real hardware (as opposed to virtual hardware) the RTC clock is distant from the CPU (in bus terms) and implemented in low speed semi-conductor technology. The system clock (AFAIK several clocks but the documentation is at the limit of my comprehension) is in the CPU and implemented in high speed semi-conductor technology. Given that a computer reads the clock very often the system system clock is a much better option for performance.

The RTC clock is optimised for its job -- to keep time when the system is powered off. This requires low power consumption because it is battery-driven and does not require a fast read cycle -- it is read once during boot and written once during shutdown when it is synchronised to the system time.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ntpd gives me non-local time, how can I fix it? inbayarea2010 Linux - Server 2 02-10-2011 03:57 AM
Timzone Issues...Local Time versus UTC time? as400 Solaris / OpenSolaris 12 09-26-2008 12:40 PM
Time is not using local time but uses UTC acummings Debian 2 11-03-2007 01:58 PM
Change UTC to LOCAL TIME in etch?? slackass Debian 4 08-03-2007 05:39 PM
ntpd not correcting local time plythgam Linux - Software 1 08-16-2004 04:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration