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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-15-2017, 01:23 PM
|
#1
|
LQ Newbie
Registered: Mar 2017
Posts: 3
Rep: 
|
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
|
|
|
03-15-2017, 02:01 PM
|
#2
|
LQ Guru
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 8,268
|
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.
|
|
|
03-15-2017, 02:31 PM
|
#3
|
Moderator
Registered: Aug 2002
Posts: 26,762
|
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.
|
03-15-2017, 09:26 PM
|
#4
|
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
|
I tend to use date, hwclock, and tzselect to manage time on my machines.
I'll set the date with
then use
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.)
|
|
|
03-16-2017, 03:41 AM
|
#5
|
Member
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567
|
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.
|
|
|
03-16-2017, 01:51 PM
|
#6
|
LQ Newbie
Registered: Mar 2017
Posts: 3
Original Poster
Rep: 
|
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.
|
|
|
03-16-2017, 02:38 PM
|
#7
|
Moderator
Registered: Aug 2002
Posts: 26,762
|
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.
|
03-16-2017, 03:08 PM
|
#8
|
LQ Newbie
Registered: Mar 2017
Posts: 3
Original Poster
Rep: 
|
i will consider you suggestions. Thanks.
|
|
|
All times are GMT -5. The time now is 07:50 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|