The following are some steps to help you set the date and time under Linux, and include a little ntpd time synchronization. The special reminder is that in the release version the limit is Red Hat series, including Fedora,centos,redflag,unbreakable Linux and so on.
There are two clocks to configure in Linux, the hardware clock and the system clock. The hardware clock determines the system clock on system boot. While the system was running, changes to one of these doesn ' t affect the other.
Under Linux There are two clocks that need to be configured, hardware clocks and system clocks. The hardware clock determines the system clock when the system is started, and when the system is running, modifying any of them does not take effect on the other default.
Note:it ' s best to set the hardware clock and have the system clock is set upon a reboot. Changing the system clock by using the date program on a running system could cause date discontinuities and consequently Problems. If you are using NTPD, you probably don ' t need to set either of this clocks (unless the current time are more than 100 0s off the real time). Just setup ntpd and let ntpd adjust the time (it'll do it in small steps to keep system timestamps).
Most distributions now offer clock-setting tools in the graphical interface, such as Kde,gnome, which has a friendly graphical tool, which is not much to say.
You can use Timeconfig to configure the timezone and UTC settings. Timeconfig would update/etc/sysconfig/clock And/etc/localtime.
Set the time zone manually if not already set.
Linux uses the file/etc/localtime to determine the time zone. This file should is either a copy of the appropriate timezone file from the Directory/usr/share/zoneinfo or a symbolic li Nk. If your time zone are incorrect, create a symbolic link to the appropriate file.
# ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime
Set whether Hwclock uses local time or UTC
Edit The File/etc/sysconfig/clock and change ' utc= ' to true or false.
If You are have a dual-boot system with Windows, the using UTC may cause problems for Windows.
Set The system clock
# date MMDDHHMMCCYY.SS
where MM is month, DD are day, HH is hour, MM is minutes,
Ccyy Is year and the SS is seconds. Time should is in 24-hour notation.
to only set the time:
# date-s HH:MM:SS
Set the hardware clock
to set the hardware clock to the System clock:
# Setclock
This method looks at/etc/sysconfig/clock to determine whether the hardware clock is set To UTC
Another method:
# hwclock--systohc# hwclock--SYSTOHC--UTC
Use the second option if in UTC.
Set Hwclock manually:
# hwclock--set--date= ' 9/22/96 16:45:05 '
Everytime use the Hwclock--set command,
It'll create or edit the File/etc/adjtime to deTermine the systematic drift.
Once You have some history,
your can use the--adjust option to adjust the hardware clock.
Run as a cron job if you are want the clock to adjust automatically on a regular schedule.
Don t use the--adjust function when using ntpd since NTPD would turn the "one Minute mode" on,
which is best left Alone. The Hwclock manpage for more info.
Setup ntpd for automatic synchronization with a remote server.
Run Red Hat ' s setup utility to make ntpd start on the boot up and edit/etc/ntp.conf
Set server and Fudge OPTIONS:
server Time.nist.govfudge time.nist.gov stratum
Enable multicastclient:
Multicastclient # Listen on default 224.0.1.1
EDIT/ETC/SYSCONFIG/NTPD if necessary. The default should be fine.
Start the ntpd daemon:
# service ntpd start