LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux time change after reboot (https://www.linuxquestions.org/questions/linux-newbie-8/linux-time-change-after-reboot-399758/)

yytan 01-05-2006 04:52 AM

Linux time change after reboot
 
hi;

i'm using linux 7.2. recently, i've no idea why the server date time will always auto change in advance 7 hours after i've reboot the machine.

appreciate for help, tq.

timmeke 01-05-2006 05:12 AM

Might be that your server is running a wrongly configured ntp daemon.
NTP (network time protocol) syncs your machine's clock with that of an NTP servers and is
mainly used to establish the same time on a bunch of machines.

Maybe your timezone isn't correctly set up. If the difference is exactly 7 hours.

yytan 01-05-2006 05:56 AM

can u tell me where to configure or check NTP ?

my timezone = singapore, have set correctly.

timmeke 01-05-2006 07:48 AM

Try looking in /etc/ntp.conf
The NTP daemon uses some files in /etc/ntp/ too. But those aren't config files.

The comments in ntp.conf should explain what you need.
More specifically, look especially at the "server ..." lines.

There are global NTP servers around that you can query. But, in order to be polite to everybody
else on the planet who are also using them, you should restrict your queries to them, for instance to
one machine. This machine can then become your local NTP server for all your other machines (which is of course faster than querying the global machines).

pixellany 01-05-2006 08:52 AM

What is "Linux 7.2" You mean RedHat? SUSE?

You should have an option as to how to set the hardware clock. The Unix default is to set it to UTC (GMT)

I think NTP should work regardless of how you tell your clock to display????

timmeke 01-05-2006 09:09 AM

Indeed. NTP just synchronizes your system's internal clock (rtc - real time clock) to the clock
on an NTP server.

How you display this clock is up to you, I suppose. But this is what I meant by "setting up the timezone".

RedHat/Fedora provide a graphical interface for setting the system date/time. I suppose other Linux distros will do the same. In this "date/time properties" window, you can also configure your system to use NTP and choose an appropriate timezone.

On my RedHat box, I can access this interface by clicking with the right mouse button on the displayed date/time on the desktop and choosing "Adjust Date & Time" from the menu that appears.

yytan 01-06-2006 06:08 AM

hi;
i'm using redhat 7.2

i've checked cmd with ,
$ date
$ hwclock -u
all return correct time & zone. duno wher has gone wrong.

again, my question is, how to fix my prob " server date time will always auto change in advance 7 hours after i've reboot the machine. "

really appreciate if some one can point me guides.

timmeke 01-06-2006 06:18 AM

My point is, if you have NTP daemon running, the clock will correct itself after a little while, no matter what it has done at reboot.

If I understand correctly, your clock changes automatically at reboot (which is normal, I suppose).
It's supposed to re-align itself to your hardware clock, called the real time clock (rtc).
NTP interferes only after the launch of the ntp daemon (ntp service) during the boot sequence.
It should however update not only your system clock, but also the hardware clock.

Can you also please clarify your problem a little? My English isn't so great.
More precisely, what do you mean with "in advance 7 hours"? Does it jump to 7 hours more (or less) than the real time? Or does it change 7 hours after the reboot?

yytan 01-06-2006 06:23 AM

timmeke;

thanks for your response.

1) how to check NTP daemon whether is runing?

2) let say now is 10:00:00 (10am), i restart my server, then when it comes to login, it display the time as 17:xx:xx (5pm)

for your information:
- $date & hwclock return same time now
- $cat /etc/sysconfig/clock
ZONE = ASIA/ SINGAPORE
UTC = false
ARC = false

Hope to hear from you soon.

amosf 01-06-2006 06:24 AM

Wow Rad Hat 7.2... That takes me back a few years...

timmeke 01-06-2006 07:24 AM

To check if the ntp daemon, called ntpd is running, you can try either:
ps -efl | grep -i ntpd
/sbin/service ntpd status
/sbin/chkconfig --list |grep ntpd #check if it's "on" for your runlevel (probably either 3 or 5).

My next question. Where does it display "17:xx:x"? What does "date" say? and "hwclock"?
Is the time that's displayed for the right timezone? Your /etc/sysconfig/clock file seems to be OK.

yytan 01-06-2006 07:37 AM

this is the result:

[!] /opt/jakarta-tomcat-4.1.24/logs>ps -efl | grep -i ntpd
0 S root 7747 11372 0 75 0 - 924 pipe_w 21:23 pts/2 00:00:00 grep -i ntpd

[!] /sbin>service ntpd status
ntpd is stopped
[!] /sbin>
[!] /sbin>chkconfig --list |grep ntpd
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[!] /sbin>


Yes, date & hwclock display as 17:xx:xx hr, (5pm)
17:xx:xx display on the bottom right corner, time properties, with correct time zone.

timmeke 01-06-2006 08:24 AM

As you can clearly see, your ntp daemon isn't running (no ntpd process in the "ps" output and "ntpd
is stopped" message from "service" program. chkconfig --list shows that ntpd will also not be restarted
at each reboot (or runlevel change), but it should.

To start ntpd, follow the following steps:
*Check the ntp config
*If the config is OK, type (as root):
/sbin/service ntpd start
/sbin/chkconfig --level 345 ntpd on
The first one will start "ntpd" directly.
The second command (chkconfig) will make ntpd run at runlevels 3, 4 and 5 (ie when reboot is successful).

When ntpd is running, it will adjust your clock, but it may take a while before the clock shows the right time.

yytan 01-08-2006 11:54 PM

Hi;

can u tell me, why do i need to start ntpd? i've another server which not started ntpd process, but when i do server reboot, the time display alright.

i've read ntpd will syn the hwclock thru satellite?

timmeke 01-09-2006 02:06 AM

You can also change the hardware clock manually, instead of using ntpd.
But your hardware clock can run slightly too fast or too slow, which implies that you need to adjust it
in the future (ie after a few years) or that you need to live with the fact that your clock is slightly off.

Changing the hardware clock can be done with the methods described above (changing your Linux clock should alter the hardware clock too) or from the BIOS.

I don't know the actual mechanism behind the NTP system, but you don't need to know it. The important fact is that with NTP, you have assurance that your clock is (as good as) correct.
But, it seems likely that somewhere, there is an atomic clock that defines (standardizes) the clock for everybody. This clock may be propagated via satellite to a few global NTP servers, that you can query to get the right clock.


All times are GMT -5. The time now is 11:09 PM.