Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
cancel
Showing results for 
Search instead for 
Did you mean: 

System Time wrong...

SOLVED
Go to solution
John Collier
Esteemed Contributor

System Time wrong...

Seems as if two of my FC4 boxes are not updating via NTP as I would expect them to while the other one is working like a champ.

I have checked to verify that the NTP service is running on all of them and it is.

ps -ef | grep ntp | grep -v grep
ntp 2879 1 0 Feb10 ? 00:00:13 ntpd -u ntp:ntp -p /var/run/ntpd.pid

They all give the same info for the above command (with the PID being different, of course), yet they all seem to be displaying different times.

What am I overlooking?
"I expect to pass through this world but once. Any good, therefore, that I can do, or any kindness that I can show to any human being, let me do it now. Let me not defer or neglect it, for I shall not pass this way again." Stephen Krebbet, 1793-1855
11 REPLIES
Ivan Ferreira
Honored Contributor

Re: System Time wrong...

The command to test if you are synchronizing the time correctly is:

ntpq -pn

You should see a list like this:

remote refid st t when poll reach delay offset jitter
==============================================================================
*10.10.10.10 146.164.48.5 2 u 56 64 377 -0.023 390.197 148.586

The * indicates that that is the server for this node. If you don't see the "*", stop the ntpservice and run:

ntpdate -b ntp.server

And start the service. Also ensure that no firewall is blocking the connection to the ntp server.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
John Collier
Esteemed Contributor

Re: System Time wrong...

Ivan,

All three of them (the one working and the two not) are on the same network going through the same router and using outside, public time servers.

Each of them have several entries when I run the ntpq -pn command:

From the working system:

+80.127.4.179 .PG0A. 1 u 441 1024 377 145.249 -0.761 1.130
+72.3.133.147 129.6.15.29 2 u 383 1024 377 27.063 -0.238 1.689
-64.172.230.138 164.67.62.194 2 u 72 1024 377 86.241 11.109 12.325
66.187.224.4 .INIT. 16 u - 1024 0 0.000 0.000 4000.00
*66.187.224.4 .CDMA. 1 u 403 1024 377 63.016 0.233 1.113

From the first non-working system:

+192.36.143.151 .PPS. 1 u 758 1024 377 186.287 -13.942 7.197
-24.34.79.42 132.163.4.103 2 u 737 1024 377 88.984 1.932 1.774
-64.112.189.11 128.10.252.6 2 u 589 1024 377 81.008 2.090 6.420
+66.187.233.4 .CDMA. 1 u 680 1024 377 52.510 -6.552 4.299
*66.187.224.4 .CDMA. 1 u 974 1024 375 63.270 -3.971 3.298

And from the last non-working system:

-64.34.193.47 195.137.27.138 3 u 879 1024 377 75.975 -11.893 7.095
-64.81.84.140 216.52.237.152 3 u 825 1024 377 78.760 -51.992 5.749
+216.237.126.10 132.239.1.6 2 u 831 1024 377 66.145 0.571 1.970
+66.187.233.4 .CDMA. 1 u 849 1024 377 71.435 -8.258 14.280
*66.187.224.4 .CDMA. 1 u 15 1024 377 64.283 0.236 1.794

As you see, all of them have an * next to the same entry, yet they all display different times. Do I have a "ghost in the machine" thing going on here?
"I expect to pass through this world but once. Any good, therefore, that I can do, or any kindness that I can show to any human being, let me do it now. Let me not defer or neglect it, for I shall not pass this way again." Stephen Krebbet, 1793-1855
Ivan Ferreira
Honored Contributor

Re: System Time wrong...

Check your timezone configuration. Verify the file /etc/sysconfig/clock. If you do some changes, reboot your computer.

How bad is the time displayed?

What is the ouput of:

date +%z
date +%Z
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
John Collier
Esteemed Contributor

Re: System Time wrong...

Looking at all the /etc/sysconfig/clock files I see that they are all identical:

ZONE="America/North_Dakota/Center"
UTC=false
ARC=false


The one that is correct and one of the others (that is not) both have the same output from the two commands:

date +%z
-0600

date +%Z
CST


The last one displays something slightly different:

date +%z
+0000

date +%Z
UTC


This tells me that the last one is in the wrong time zone (UTC vs CST). I forget where to change that since it is usually a set-and-forget type thing, but it does not explain why the two that are set the same still display differnt times.

Guess the first thing to do is to find where to change the one to the UTC and then move on from there...
"I expect to pass through this world but once. Any good, therefore, that I can do, or any kindness that I can show to any human being, let me do it now. Let me not defer or neglect it, for I shall not pass this way again." Stephen Krebbet, 1793-1855
Ivan Ferreira
Honored Contributor

Re: System Time wrong...

The time is displayed wrong because there is something bad with your time zone configuration. Your GMT-UTC offset is different, and that's why you get the wrong date. Verify if you have set the TZ environment variable.

echo $TZ
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ivan Ferreira
Honored Contributor
Solution

Re: System Time wrong...

You can also try replacing your current /etc/localtime file with a fresh one:

cp /usr/share/zoneinfo/America/North_Dakota/Center /etc/localtime

This is executed at boot time according to the configuration of /etc/sysconfig/clock
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
John Collier
Esteemed Contributor

Re: System Time wrong...

Ivan,

Thanks for the input. I am at work now, but I will see what I can do with the systems when I get home.

Silly question:

In order to make any of these suggestions work, you have to make these changes as root, right?
"I expect to pass through this world but once. Any good, therefore, that I can do, or any kindness that I can show to any human being, let me do it now. Let me not defer or neglect it, for I shall not pass this way again." Stephen Krebbet, 1793-1855
Ivan Ferreira
Honored Contributor

Re: System Time wrong...

The replacement of the /etc/localtime file you must do as root, but the TZ environment variable is per user configurable. If you want to configure it for all users, add it to /etc/profile:

export TZ="zonename"
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
John Collier
Esteemed Contributor

Re: System Time wrong...

Ivan,

It would seem as if I do not have the TZ environment variable set. When I run the

echo $TZ

I get no response at all. Just another command prompt.

I did take your advise and copied over a fresh localtime file using the command you suggested. What got my attention is that it did not complain about overwriting a file when I ran the command as I would have expected. Now i wish I would have checked the existence of the file prior to running the command. Oh well.

Now that it is copied over, I have to wait until she is no longer using it to reboot.

Strange thing. Seems as if the $TZ is not set on any of the boxes, but yet one of them is fine. I guess I still have a great deal of learning to do in regards to setting system time in Linux.

I will update this thread when there is something more to report.

Thanks for all the help so far!
"I expect to pass through this world but once. Any good, therefore, that I can do, or any kindness that I can show to any human being, let me do it now. Let me not defer or neglect it, for I shall not pass this way again." Stephen Krebbet, 1793-1855
Ivan Ferreira
Honored Contributor

Re: System Time wrong...

You don't have to reboot the system if you did the cp command. You only need to reboot if you change the /etc/sysconfig/clock file and do not run the cp command.

The TZ variable could not be defined, by default, it's not defined. I just told you to check that just in case.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
John Collier
Esteemed Contributor

Re: System Time wrong...

Time on all boxes now correct. Thanks for the help!
"I expect to pass through this world but once. Any good, therefore, that I can do, or any kindness that I can show to any human being, let me do it now. Let me not defer or neglect it, for I shall not pass this way again." Stephen Krebbet, 1793-1855