Centos系统时间同步及验证

[root@test2 ~]# date               #检查系统时间是否和当前时间一致
2024年 04月 01日 星期一 10:34:49 CST


[root@test2 ~]# yum -y install ntpdate    ntpdate命令是用来设置本地日期和时间


[root@test2 ~]# tzselect        #设置时区,选择Asia→China→Beijing Time→Yes(即5、9、1、1序号)
...
You can make this change permanent for yourself by appending the line TZ='Asia/Shanghai'; export TZ to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai       #看到这个说明设置时区成功


[root@test2 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: "/usr/share/zoneinfo/Asia/Shanghai" 与"/etc/localtime" 为同一文件


[root@test2 ~]# ntpdate cn.pool.ntp.org     #http://cn.pool.ntp.org是位于中国的公共NTP服务器
 5 Apr 17:19:18 ntpdate[39500]: step time server 84.16.67.12 offset 368881.951125 sec


[root@test2 ~]# hwclock -w            #或hwclock-systohc,将系统时钟同步到硬件时钟


[root@test2 ~]# date                  #再次验证
2024年 04月 05日 星期五 17:13:27 CST

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值