LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-15-2017, 01:23 PM   #1
ziglik
LQ Newbie
 
Registered: Mar 2017
Posts: 3

Rep: Reputation: Disabled
system clock. date


Hello Everyone. I manage about 60 RHEL 6.X servers that are scattered around the country. The question is which file or directory feeds the output for a "date" command? For instance, when i run the "date" program on the server that is physically located in Chicago it shows the local time for Chicago despite the fact that the /etc/sysconfig/clock file shows "Zone=America/New-York". After surfing through the config files i noticed an entry for "192.168.168.1 timerouter" in /etc/hosts files does it mean that the system takes its time from that system with the ip of 192.168.168.1? If it is not where does the system takes its time from and what does that entry mean in /etc/hosts file "192.168.168.1 timerouter"? Thanks
 
Old 03-15-2017, 02:01 PM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 8,268
Blog Entries: 21

Rep: Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787Reputation: 4787
The date command shows the system time, which is always local time, irrespective of hardware clock setting (usually UTC on a Linux box). I have little experience with Red Hat distros, but if the /etc/sysconfig/clock file is similar to the one in LFS, then it will indicate the kind of time the hardware clock is set to.

To find out if the time is being set from the hardware clock or from a timeserver, you need to use timedatectl.

Last edited by hazel; 03-15-2017 at 02:03 PM.
 
Old 03-15-2017, 02:31 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,762

Rep: Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322
Welcome to LinuxQuestions.

timedatectl is for systems using systemd but RHEL 6.x does not. If it was a hardware clock UTC/local error then the difference in time would be the UTC offset.

If you read the notes in the /etc/sysconfig/clock file it states that the actual timezone is defined by the contents of /etc/localtime. /etc/localtime is a binary file so to see its timezone setting run the command

zdump /etc/localtime

At face value what you see in the hosts file is just a manual reference of an IP address to a hostname. If your system is actually using the timerouter for syncing look at the contents of the /etc/ntp.conf file.

Last edited by michaelk; 03-15-2017 at 02:34 PM.
 
1 members found this post helpful.
Old 03-15-2017, 09:26 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,902
Blog Entries: 28

Rep: Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350Reputation: 6350
I tend to use date, hwclock, and tzselect to manage time on my machines.

I'll set the date with

Code:
date -s [string]
then use

Code:
hwclock --set
to set the hardware clock to the time established by the date command.

tzselect is a neat little script for selecting your time zone.

(I have to muck with time so seldom that I had to check the man pages to remind me of the appropriate arguments.)
 
Old 03-16-2017, 03:41 AM   #5
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Hi,

What you should verify is what time is actually on the motherboard on each machine. The zone in sysconfig could well be New York but the time on the hardware clock set to something else. The machine will know by itself what time is correct.

I'll give you an example:

My laptop has a time corresponding to UTC, i.e. the time at longitude 0 degrees on Earth. But I live in a region where the time zone is +4 hours. So, my Linux is configured such that /etc/sysconfig/clock will contain "UTC=true" and "ZONE=Indian/Mauritius". The ZONE variable contains the filename of your corresponding time zone as found in /usr/share/zoneinfo. You can also check out /etc/localtime, which should reflect the ZONE variable.

So, when I run the date command, Linux checks hardware clock if UTC or localtime, then makes the necessary adjustments so that the localtime is displayed everytime.

To check the hardware clock you can use the hwclock command. Please read the man pages for all the details.
 
Old 03-16-2017, 01:51 PM   #6
ziglik
LQ Newbie
 
Registered: Mar 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks to all of the participants.

So, it looks like my systems set its date and hwclock by running the ntpdate via cron job against the ntp server on an hourly basis and the system adjusts its time to a local time by looking at /etc/localtime (assuming that the ntp server feeds the given system with UTC time).
I came to this conclusion according to the below variables:
a) /etc/sysconfig/clock = "Zone=America/New York" (as michaelk mentioned this file can be disregarded since the system in fact looks at /etc/localtime for a time zone)
b) /etc/localtime = corresponds to the timezone of where the server is physically located
c) /etc/ntp.conf = ntp.random.org is enabled
d) crontab -l = 0 0-23 * * * ntpdate ntp.random.org

Is there anyway to know if the ntp server corresponds to the UTC time or not? Or is it a standard that any NTP server would correspond to UTC time?

I have no IDEA why the systems have to know about the timerouter entry in /etc/hosts file, i don't see any need for it so far. The ip address for a timerouter is different from the IP of a NTP server in /etc/hosts file.

i hope i have it right. Any comments are welcomed.

PS. Just starting my project of managing these servers, and i lack documentation and Linux knowledge.

Thanks to all.
 
Old 03-16-2017, 02:38 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,762

Rep: Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322Reputation: 6322
The system clock and ntp use UTC as a reference. The date command uses the timezone information to display local time.

Running the ntp daemon is preferred over using ntpdate (which is deprecated) because time changes are gradual instead of a time jump. It also tunes the system clock so it keeps accurate time.

You would have to ask the people that setup the servers as to why they added the server to the hosts file. Your company might of used a local time server at one time.

Did you post your real settings from crontab and ntp.conf? As far as I know ntp.random.org does not exist. You should use the US ntp pool.

Quote:
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

Last edited by michaelk; 03-16-2017 at 02:42 PM.
 
1 members found this post helpful.
Old 03-16-2017, 03:08 PM   #8
ziglik
LQ Newbie
 
Registered: Mar 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
i will consider you suggestions. Thanks.
 
  


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
Setting system date and time affecting the clock and date on BIOS satimis Ubuntu 7 09-21-2007 08:02 AM
Change the date format in the system tray clock bobbrandt SUSE / openSUSE 2 06-07-2007 01:19 PM
Slow system clock and stray hardware clock, pleas help! Epox Linux - General 6 01-02-2007 02:43 PM
Adjust system date to hardware clock Winanjaya Linux - General 1 10-13-2006 05:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:50 AM.

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