CentOS7和8 同步时间、时区

CentOS7和CentOS8 同步时间、时区

1、CentOS7 通过yum安装ntp同步时间

  • 安装ntpdate工具
    sudo yum -y install ntp ntpdate
  • 设置系统时间与网络时间同步
    sudo ntpdate cn.pool.ntp.org
  • 将系统时间写入硬件时间
    sudo hwclock --systohc

2、CentOS8 通过yum安装ntp同步时间

  • 添加wlnmp源
    rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
  • 安装ntp服务
    yum install wntp
  • 时间同步
    ntpdate ntp1.aliyun.com

3、centos 同步时区

  • cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

你可能感兴趣的:(Linux-CentOS)