Over time, the computer clock tends to drift. Network Time Protocol (NTP) is a way to ensure that your clock remains accurate. NTP service is installed by default on the general system
If you can use the following command to view
[Root@wap etc]# Rpm-qa |grep NTP
ntp-4.2.0.a.20040617-4.el4.1
NTP service, consisting mainly of four files
/etc/ntp.conf The main configuration file for the NTP service.
/usr/share/zoneinfo a time setting file for each major time zone, such as Shanghai/usr/share/zoneinfo/asia/shanghai
/etc/sysconfig/clock; Linux's main time zone settings file, each boot after the Linux operating system read this file to set the system preset to display the time, such as: "Zone=asia/shanghai
/etc/localtim the time setting file for the local system.
/bin/date Linux system above date and time modification and output command
/sbin/hwclock the BIOS time of the host computer with the Linux system time is adjusted by the date this instruction only affects the system time. If you change the BIOS time, you need to use the Hwlock command
/USR/SBIN/NTPD; The daemon process for NTP services
/usr/sbin/ntpdata; The NTP client is used to connect to the NTP server command file
/USR/SBIN/NTPQ Standard Network Timing Protocol (NTP) query program
Configuration
[Root@wap etc]# vi/etc/ntp.conf
Restrict default Ignore
Ignore all NTP requirements packet
Restrict 127.0.0.1
Restrict 218.0.0.0 mask 255.255.255.248 nomodify
Restrict 202. 0.0.0 Mask 255.255.255.0 nomodify
Restrict 61. 0.0.0 Mask 255.255.255.0 nomodify
Restrict can be restricted for subnets, IP, nomodify parameters indicate that the client can perform the server-side, but cannot change the server-side parameters
Server 0.pool.ntp.org
Server 1.pool.ntp.org
Server 2.pool.ntp.org
Note: Server option specifies which server to use, each server is a separate line, and if prefer (preference) parameters are specified on a single server
Restrict 0.pool.ntp.org
Restrict 1.pool.ntp.org
Restrict 2.pool.ntp.org
If the restric is not followed by a parameter, it means that all permissions can be allowed
Server 127.127.1.0 # Local clock
Fudge 127.127.1.0 Stratum 10
Driftfile/var/lib/ntp/drift
Driftfile option, a file is specified to hold the system clock frequency deviation, which is used by the NTPD program to automatically compensate for the natural drift of the clock so that the clock remains fairly accurate even when the external source is cut off
Broadcastdelay 0.008
Logfile/var/log/ntp.log
Keys/etc/ntp/keys
Client settings:
Set by crontab timer, run once every 5 minutes
*/5 * * * */usr/local/wapsh/ntprsync.sh
[Root@appserver wapsh]# Cat ntprsync.sh
#!/bin/sh
/usr/sbin/ntpdate 218.0.0.1
/sbin/hwclock–w
Here 218.0.0.1 is the server-side IP, so the client synchronizes time with the server every 5 minutes.