I am running CntOS 5 with Gnome. Every now and then I have noticed that the computer will somehow get the time wrong by several hours. Is there a simple way to adjust the time? So far the only way I have found is to boot into windows (it is a dual boot system), make the change there, and then get back into CentOS. Older versions of Red Hat and Fedora let you do it by right-clicking on the time display, if I recall correctly, but setting the time isn't one of the options in CentOS.
Thanks
Buz Davis
On Sun, 6 Feb 2011, Buz Davis wrote:
To: centos@centos.org From: Buz Davis buzdavis@earthlink.net Subject: [CentOS] system clock
I am running CntOS 5 with Gnome. Every now and then I have noticed that the computer will somehow get the time wrong by several hours. Is there a simple way to adjust the time? So far the only way I have found is to boot into windows (it is a dual boot system), make the change there, and then get back into CentOS. Older versions of Red Hat and Fedora let you do it by right-clicking on the time display, if I recall correctly, but setting the time isn't one of the options in CentOS.
If you are connecting to the internet, you can use a program called ntpd:
Name : ntp Arch : i386 Version : 4.2.2p1 Release : 9.el5.centos.2.1 Size : 2.4 M Repo : installed Summary : Synchronizes system time using the Network Time Protocol (NTP). URL : http://www.ntp.org License : distributable Description: The Network Time Protocol (NTP) is used to synchronize a : computer's time with another reference time source. The ntp : package contains utilities and daemons that will synchronize : your computer's time to Coordinated Universal Time (UTC) via : the NTP protocol and NTP servers. The ntp package includes : ntpdate (a program for retrieving the date and time from remote : machines via a network) and ntpd (a daemon which continuously : adjusts system time). : : Install the ntp package if you need tools for keeping your : system's time synchronized via the NTP protocol.
HTH
Keith Roberts
----------------------------------------------------------------- Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk
All email addresses are challenge-response protected with TMDA [http://tmda.net] -----------------------------------------------------------------
On 02/06/2011 01:35 PM, Buz Davis wrote:
I am running CntOS 5 with Gnome. Every now and then I have noticed that the computer will somehow get the time wrong by several hours. Is there a simple way to adjust the time? So far the only way I have found is to boot into windows (it is a dual boot system), make the change there, and then get back into CentOS.
[...]
CentOS likes to store the hardware system clock in GMT time. Windows likes to store it in the local time zone. The multi-hour switch is an artifact of dual booting with this disparity in play. If either system updates the hardware clock while running, the other OS will get thrown off by several hours.
The fastest way to 'resync' the clock is using the ntpdate utiltity. It is part of the 'ntp' package. As root run: 'yum install ntp'. You can then reset the clock in CentOS by running 'ntpdate' as root.
On 6 Feb 2011, at 21:40, Buz Davis buzdavis@earthlink.net wrote:
Is there a simple way to adjust the time?
Easy way - use the 'date' command, see http://linux.die.net/man/1/date
Ben
On Sun, 6 Feb 2011, Benjamin Donnachie wrote:
To: CentOS mailing list centos@centos.org From: Benjamin Donnachie benjamin@py-soft.co.uk Subject: Re: [CentOS] system clock
On 6 Feb 2011, at 21:40, Buz Davis buzdavis@earthlink.net wrote:
Is there a simple way to adjust the time?
Easy way - use the 'date' command, see http://linux.die.net/man/1/date
Could do Ben. But the idea of ntp is that it does it for you automatically, without having to intervene yourself and set the time manually :)
Kind Regards,
Keith Roberts
----------------------------------------------------------------- Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk
All email addresses are challenge-response protected with TMDA [http://tmda.net] -----------------------------------------------------------------
On 6 February 2011 22:33, Keith Roberts keith@karsites.net wrote:
Could do Ben. But the idea of ntp is that it does it for you automatically, without having to intervene yourself and set the time manually :)
Agreed but OP asked, "Is there a simple way to adjust the time?".
Ben
On Sun, Feb 06, 2011 at 10:56:11PM +0000, Benjamin Donnachie wrote:
On 6 February 2011 22:33, Keith Roberts keith@karsites.net wrote:
Could do Ben. But the idea of ntp is that it does it for you automatically, without having to intervene yourself and set the time manually :)
Agreed but OP asked, "Is there a simple way to adjust the time?".
Depending upon OP's needs, as they are going to be dual booting, as far as I can tell from the post, the simplest thing would be to set the CentOS install to use localtime.
To do that, edit /etc/adjtime. You'll see it says UTC. Change that to LOCAL
Reboot. (Might be a way to put it into effect without a reboot, but I don't know) Run ntpdate pool.ntp.org which will set the time.
Now, when you boot between the two of them, Windows and Linux, the time will stay the same. The problem is that both systems set the hardware to clock time when shutting down.
On Sun, Feb 6, 2011 at 4:35 PM, Buz Davis buzdavis@earthlink.net wrote:
I am running CntOS 5 with Gnome. Every now and then I have noticed that the computer will somehow get the time wrong by several hours. Is there a simple way to adjust the time? So far the only way I have found is to boot into windows (it is a dual boot system), make the change there, and then get back into CentOS. Older versions of Red Hat and Fedora let you do it by right-clicking on the time display, if I recall correctly, but setting the time isn't one of the options in CentOS.
To summarize what others have said:
1) The disparity is caused by using different clock settings from Linux to Windows. Deselect UTC to make it use local time. 2) Use ntpdate to sync the time.
A few other points:
1) Linux maintains both a system and a hardware clock. On bootup, the system copies the hardware clock to the system time. There can be drift between the two clocks (especially in virtual environments), so on shutdown the system does a sync from the system to the hardware clock.
2) The ntpd daemon will not adjust the system time beyond a few minutes. If you want to hard set the time, you need to use ntpdate first then turn on ntpd to keep it accurate. ntpdate does allow the system to slowly adjust the clock and this is useful to keep logs sane.
3) Be careful when forcing a time change on a running system. Time shifting backwards can wreak havoc on certain applications such as databases.
On Sun, Feb 6, 2011 at 7:56 PM, Kwan Lowe kwan.lowe@gmail.com wrote:
On Sun, Feb 6, 2011 at 4:35 PM, Buz Davis buzdavis@earthlink.net wrote:
I am running CntOS 5 with Gnome. Every now and then I have noticed that the computer will somehow get the time wrong by several hours. Is there a simple way to adjust the time? So far the only way I have found is to boot into windows (it is a dual boot system), make the change there, and then get back into CentOS. Older versions of Red Hat and Fedora let you do it by right-clicking on the time display, if I recall correctly, but setting the time isn't one of the options in CentOS.
To summarize what others have said:
- The disparity is caused by using different clock settings from
Linux to Windows. Deselect UTC to make it use local time. 2) Use ntpdate to sync the time.
A few other points:
- Linux maintains both a system and a hardware clock. On bootup, the
system copies the hardware clock to the system time. There can be drift between the two clocks (especially in virtual environments), so on shutdown the system does a sync from the system to the hardware clock.
- The ntpd daemon will not adjust the system time beyond a few
minutes. If you want to hard set the time, you need to use ntpdate first then turn on ntpd to keep it accurate. ntpdate does allow the system to slowly adjust the clock and this is useful to keep logs sane.
- Be careful when forcing a time change on a running system. Time
shifting backwards can wreak havoc on certain applications such as databases.
ntpdate is normally executed at boot tiime by the ntp init script. If you're on an unconnected wireless or modem at the time, this command will fall through to using the local hardware clock, which is listed as a "fudge" server in ntp.conf, just in case you can't reach the real NTP servers.
On Sunday, February 06, 2011 04:35:48 pm Buz Davis wrote:
I am running CntOS 5 with Gnome. Is there a simple way to adjust the time?
Use system-config-date (in the GNOME menu: System/Administration/Date&Time)
Make sure 'System clock uses UTC' is unchecked in the timezone tab if you dual-boot with windows and don't have windows set to that setting. You can set up network stime servers in the 'Network Time Protocol' tab, and you can adjust the date and time easily in the 'Date & Time' tab.