Time synchronization date;hwclock-r
1.
Date displays the system time
Date-s 10:10:10 set system time
When date-s "10:00:00 on 2018-8-8" sets the system time, if you still need to set a date, wrap the date and time values in double quotation marks
Hwclock or clock displays the hardware time. Time in BIOS on motherboard
A command to see the time date;hwclock-r
# hwclock-w writes the system time to the system hardware
Hwclock-s writes the hardware time to the system time:
two.
Stand-alone school time (can only be connected to the Internet)
Available network time servers:
Time.windows.com
Tock.stdtime.gov.tw
Ntp.api.bz
Ntpdate 0.cn.pool.ntp.org
Ntpdate ntp1.aliyun.com
Time synchronization, Linux system needs to install ntpdate
Check whether ntpdate: rpm-qa is installed | grep ntpdate
If not, run the following command: yum install ntpdate
Time synchronization method (server is rarely used):
[root@clent ~] # ntpdate time.windows.com or
[root@clent ~] # / usr/sbin/ntpdate time.windows.com
Crontab scheduling tasks
Time synchronization tasks are executed regularly, so we use crontab-e to add timing tasks
# / 1 * root ntpdatetime.nuri.net;hwclock-w
That is, synchronize the internet time every other hour.
Or
You can see the writing format of scheduled tasks through the vi / etc/crontab command
/ 5 / usr/sbin/ntpdate time.windows.com # synchronize every 5 minutes
Or
/ 5 ntpdate time.windows.com # synchronize every 5 minutes
Crontab-l: lists the contents of the current user's crontab file
Note:
Solve the the NTP socket is in use, exiting problem
[root@esx4 ~] # service ntpd stop
The system time is inconsistent with the hardware time (correct, but the system time is wrong). Hwclock-s writes the hardware time to the system time failure.
Hwclock-w {Save clock} solve the problem!
3. The server uses time to synchronize the server
4. Modify system time profile
[root@localhost ~] # / etc/sysconfig/clock
# Open the clock file and change the relevant content to the following content: UTC=true ARC=falseZONE= "Asia/Shanghai"
Restart the system
[root@localhost ~] # reboot