Linux——时间

来源:互联网 发布:萤火虫壁纸软件 编辑:程序博客网 时间:2024/06/08 04:32

时间同步

1.服务端
yum install chrony -y ##安装服务
这里写图片描述
vim /etc/chrony.conf ##主配置文件
21 # Allow NTP client access from local network.
22 allow 172.25.0.0/24 ##允许谁去同步我的时间
28 # Serve time even if not synchronized to any NTP server.
29 local stratum 10 ##不去同步任何人的时间,时间同步服务器级别

systemctl restart chronyd
systemctl stop firewalld

2.客户端
vim /etc/chrony.conf
这里写图片描述
3 server 0.rhel.pool.ntp.org iburst
4 server 1.rhel.pool.ntp.org iburst====> server ntpserverip iburst
5 server 2.rhel.pool.ntp.org iburst====>
6 server 3.rhel.pool.ntp.org iburst
这里写图片描述
systemctl restart chronyd

[root@localhost ~]# chronyc sources -v
这里写图片描述

timedatectl命令
这里写图片描述
timedatectl status ##显示当前时间信息
这里写图片描述
timedatectl set-time ##设定当前时间
这里写图片描述
这里写图片描述
timedatectl set-local-rtc 0|1 ##设定是否使用utc时间

原创粉丝点击