服务器时间定时自动同步

一、系统时间

    1、硬件时间与系统时间;

(1)、UTC:通用协调时间
(2)、GMT:格林威治标准时间
(3)、CST:中国标准时间

(4)、DST:夏令时

                GMT+8=UTC+8=CST

(5)、硬件时钟
RTC或CMOS时钟,一般在主板上靠电池供电,服务器断电后也会继续运行。仅保存日期时间数值,无法保存时区和夏令时设置
(6)、系统时间
一般在服务器启动时复制RTC时间,之后独立运行,保存了时间、时区和夏令时设置。

    2、命令:timedatectl

(1)、读取时间
timedatectl 等同于 timedatectl status
(2)、设置时间
timedatectl set-time "YYYY-MM-DD HH:MM:SS"
(3)、列出所有时区
timedatectl list-timezones
(4)、设置时区

timedatectl set-timezone Asia/Shanghai

                        或者:cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

(5)、是否NTP服务器同步
timedatectl set-ntp yes
(6)、将硬件时钟调整为与本地时钟一致
timedatectl set-local-rtc 1 等同于
hwclock --sysohc --localtime 

    3、ntpdate时间同步;

(1)、ntpdate服务;
yum install -y ntpdate
ntpdate time.windows.com

    4、定时同步;

crontab -e

* * * * *   /usr/sbin/ntpdate time.windows.date   每分钟同步

猜你喜欢

转载自blog.csdn.net/zsycsnd/article/details/79740325