zoukankan      html  css  js  c++  java
  • CentOS 7时间管理

    CentOS 7时间管理

    一、CentOS 7查看时间

    1. 查看系统时间

    [root@Charramma ~]# date
    Tue Apr  6 17:35:18 CST 2021
    
    [root@Charramma ~]# date -R
    Tue, 06 Apr 2021 17:35:54 +0800
    

    2. 查看硬件时间

    [root@Charramma ~]# hwclock
    Tue 06 Apr 2021 05:36:45 PM CST  -0.226496 seconds
    

    二、CentOS 7 更新时间

    1. 更新系统时间

    1.1 手动更新系统时间

    timedatectl 修改年月日

    [root@Charramma ~]# timedatectl set-time 2018-08-30
    [root@Charramma ~]# date
    Thu Aug 30 00:00:01 CST 2018
    

    timedatectl 修改时分秒

    [root@Charramma ~]# timedatectl set-time 10:12:15
    [root@Charramma ~]# date        
    date
    Thu Aug 30 10:12:20 CST 2018
    

    直接使用 date -s 修改

    [root@Charramma ~]# date -s "2020-02-12 13:13:13"
    Wed Feb 12 13:13:13 CST 2020
    

    1.2 自动更新系统时间

    使用ntp服务设置系统时间与网络时间同步

    [root@Charramma ~]# yum install ntp -y
    [root@Charramma ~]# ntpdate cn.pool.ntp.org
    

    1.3 修改系统时区

    timedatectl list-timezones列出所有时区

    [root@Charramma ~]# timedatectl list-timezones
    [root@Charramma ~]# timedatectl set-timezone Asia/Ho_Chi_Minh
    

    或者直接复制时区文件

    [root@Charramma ~]# cp /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime
    

    2. 更新硬件时间

    2.1 手动更新硬件时间

    [root@Charramma ~]# hwclock --set --date "2020-02-23 12:12:13"
    

    2.2 自动更新硬件时间

    ntpdate命令默认只同步系统时间,可以通过修改配置让硬件时间和系统时间一起更新

    [root@Charramma ~]# sed -i 's/SYNC_HWCLOCK=no/SYNC_HWCLOCK=yes/' /etc/sysconfig/ntpdate
    [root@Charramma ~]# systemctl restart ntpdate
    [root@Charramma ~]# ntpdate cn.pool.ntp.org
    

    2.3 将系统时间写入硬件时间

    -w --systohc

    [root@Charramma ~]# hwclock --systohc
    

    或者

    [root@Charramma ~]# timedatectl set-local-rtc 1
    

    将日期写入CMOS

    [root@Charramma ~]# clock -w
    

    2.4 将硬件时间写入系统时间

    -s --hctosys

    [root@Charramma ~]# hwclock --hctosys
    
  • 相关阅读:
    Zepto结合Swiper的选项卡
    Angular选项卡
    创建简单的node服务器
    封装ajax
    JQuery和html+css实现鼠标点击放烟花
    js实现螺旋纹理特效
    Angular入门
    Angular JS例子 ng-repeat遍历输出
    Angular 基础教程(1)
    PHP数组
  • 原文地址:https://www.cnblogs.com/CharrammaBlog/p/14620703.html
Copyright © 2011-2022 走看看