First use the date command to see if the CentOS time is correct, date-r to see if time zone is right.
First determine if the NTP service is installed before using time synchronization, view command "Yum List | grep NTP, no then enter "Yum install Ntp-y" can be.
Temporary manual Time Synchronization command is "Ntpdate cn.pool.ntp.org", note: Ntpdate behind the time server, you can also use the China National Service Center Address "210.72.145.44″." After you get the exact time, use "hwclock-w" to update the ROM time.
Set automatic time synchronization using Crontab to implement, enter "Vi/etc/crontab" Add the following:
| The code is as follows |
Copy Code |
* * * * root/usr/sbin/ntpdate cn.pool.ntp.org &&/sbin/hwclock-w |
The meaning is that every night 21:30 automatically sync time, and then write Rom.
Attached crontab file format: minutes (0-59) hours (0-23) Date (1-31) month (1-12) week (0-7) User command
Synchronizing with a locally set time server
First we need to select 1 machines to do the server
Open the configuration file on this server
| The code is as follows |
Copy Code |
Vi/etc/ntp.conf Put restrict default Kod nomodify notrap nopeer noquery restrict-6 default default Kod nomodify notrap nopeer noquery
|
#掉不用
Add below
| The code is as follows |
Copy Code |
Restrict default nomodify noquery notrap Restrict native IP address mask native subnet mask nomodify
|
Save exit
| The code is as follows |
Copy Code |
Service NTPD Start
|
The machines that need to be synchronized after the
server is running
just have to follow the same approach as synchronizing the world's servers just change the domain name to your server's IP address on the line ~