1. 转载于:https://www.cnblogs.com/LouisZJ/p/8554991.html
  2.  
  3. [root@nginx ~]# timedatectl --help
  4. timedatectl [OPTIONS...] COMMAND ...
  5. Query or change system time and date settings.
  6.  
  7. -h --help Show this help message
  8. --version Show package version
  9. --no-pager Do not pipe output into a pager
  10. --no-ask-password Do not prompt for password
  11. -H --host=[USER@]HOST Operate on remote host
  12. -M --machine=CONTAINER Operate on local container
  13. --adjust-system-clock Adjust system clock when changing local RTC mode
  14.  
  15. Commands:
  16. status Show current time settings
  17. set-time TIME Set system time
  18. set-timezone ZONE Set system time zone
  19. list-timezones Show known time zones
  20. set-local-rtc BOOL Control whether RTC is in local time
  21. set-ntp BOOL Control whether NTP is enabled

查看当前设置,直接输入timedatectl等同于timedatectl status

  1. [root@tgcdn-qd-133 /root]# timedatectl \
  2. Local time: Tue 2018-03-13 10:41:20 CST
  3. Universal time: Tue 2018-03-13 02:41:20 UTC
  4. RTC time: Tue 2018-03-13 02:42:29
  5. Time zone: Asia/Shanghai (CST, +0800)
  6. NTP enabled: n/a
  7. NTP synchronized: no
  8. RTC in local TZ: no
  9. DST active: n/a
  10.  

设置当前时间:

  1. timedatectl set-time HH:MM:SS

设置当前日期:

  1. timedatectl set-time YYYY-MM-DD

默认的,系统是使用UTC时间的,可以用以下命令打开和关闭UTC时间:

  1. timedatectl set-local-rtc boolean

把 boolean 替换成yes则表示使用本地时间,替换成no则表示是UTC时间

注:这里的boolean值也可以用true、flase

设置时区:

查看所有的时区:

  1. timedatectl list-timezones

设置时区

  1. timedatectl set-timezone time_zone

远程NTP服务器同步

timedatectl还可以设置是否打开NTP选项

  1. timedatectl set-ntp boolean

这里的boolean是yes或者no

除了以上用法,timedatectl 还支持通过-H参数进行远程主机的时间设置。

查看系统时间

  1. [root@nginx ~]# date
  2. 2018 03 13 星期二 10:58:41 CST

查看硬件时间

  1. [root@nginx ~]# hwclock --show
  2. 20180313 星期二 110016 -0.086030

假如系统时间和硬件时间都不准确

更新时区

  1. [root@localhost ~]# timedatectl set-timezone Asia/Shanghai

更新日期

  1. [root@localhost ~]# timedatectl set-time 2017-06-13

更新时间

  1. [root@localhost ~]# timedatectl set-time 2017-06-13

将系统时间和硬件时间调整为一致

  1. [root@localhost ~]# timedatectl set-local-rtc 1
  2. 或者
  3. [root@localhost ~]# hwclock --systohc --localtime

将日期写入CMOS

  1. [root@localhost ~]# clock w
  1.  
 
  1.  

CentOS 7修改系统时间及硬件时间的更多相关文章

  1. CentOS 6.9系统时间和硬件时间设置(转)

    总结一下hwclock,这个容易晕: 1)/etc/sysconfig/clock 文件,只对 hwclock 命令有效,且只在系统启动和关闭的时候才有用(修改了其中的 UTC=true 到 UTC= ...

  2. CentOS 永久修改系统时间

    1.查看当前系统时间 date       2.修改当前系统时间 date -s "2018-2-22 19:10:30       3.查看硬件时间 hwclock --show      ...

  3. CentOS 系统时间与硬件时间

    date 系统时间查看 date -s 'YYYYMMDD HHMMSS' 设置系统时间 hwclock 硬件时间查看 hwclock -w 将系统时间同步到硬件时间 cp /usr/share/zo ...

  4. Centos7 修改系统时间和硬件时间不一致的问题

    查看系统时间 [root@localhost ~]# dateSat Feb 24 14:41:22 CST 2018 查看硬件时间 [root@localhost ~]# hwclock --sho ...

  5. Linux系统时间和硬件时间设置

    在Linux中有硬件时钟与系统时钟两种时钟.硬件时钟是指主机板上的时钟设备,也就是通常可在BIOS画面设定的时钟.系统时钟则是指kernel中的时钟.所有Linux相关指令与函数都是读取系统时钟的设定 ...

  6. linux 系统文件类型、系统安装时间、系统启动时间、系统运行时间、设置及显示时间、系统时间和硬件时间

    系统文件类型: 1) $mout 2) df -l:仅列出本地文件系统:-h (--human-readable):-T:文件系统类型 $df -lhf 3) file -s (--special-f ...

  7. CentOS7系统时间和硬件时间不同步问题

    CentOS7系统中有两个时间:系统时间 和 硬件时间 我们常用命令 date 会输出系统时间,用 date 命令修改的也是系统时间 硬件时间是写入到 BIOS 中的时间,用 hwclock -r 命 ...

  8. centos 7 修改系统屏幕分辨率

    centos 7 修改系统屏幕分辨率,命令方式和图形方式的修改方法. 命令:xrandr 通过命令 xrandr 修改系统的分辨率,输入xrandr: bash [admin@localhost ~] ...

  9. CentOS设置系统时间、硬件时间、以及定时校对时间

    CentOS设置系统时间和时区 一.设置时区 方法一:使用setup工具 setup 选择Timezone configuration 选择Asia/Shanghai 空格键勾选上System clo ...

随机推荐

  1. sublime text 3 ,React,html元素自动补全方法(用Emmet写法写jsx中的html)

    1. 安装emmet: Preferences -> Package Control -> Install Package -> emmet 2. 配置emmet: Preferen ...

  2. React项目中跨域问题的解决方案

    刚刚找到到通过creat-react-app创建的项目中跨域问题的解决方案,记录下来以备后用. 如果接口地址为:    http://my.example.com/eg-api  则配置package ...

  3. oracle数据库连接缓慢

    今天连接数据库时非常的慢,大概将近1分钟,才能连上,感觉不对,登录数据库所在的服务器,进行检查,常规的内存.硬盘.CPU全都正常,然后想要进入oracle用户时报错了:su: cannot set u ...

  4. 2018.5.4 Unix的五种IO模型

    阻塞非阻塞和异步同步 同步和异步关注的是消息通信机制,关注两个对象之间的调用关系. 阻塞和非阻塞关注的是程序在等待调用结果(消息,返回值)时的状态,关注单一程序. Unix的五种IO模型 以下基于Li ...

  5. Python变量和常量

    1.什么是变量 变量:核心在于变和量儿字,变->变化,量->状态如何定义? x=1 变量名 变量赋值符号:= 变量值:1 其中变量名又称为标识符: 1. 可以是字母,数字,下划线的任意组合 ...

  6. STM32的USART应用问题(不定时添加)

    ST应用的问题:串口一直在用.不检测会导致一直中断要规避. 规避范例: void USART1_IRQHandler(void) //串口1中断服务程序 { u8 Res; u8 DataCount= ...

  7. ZJOI2018 D1T2 历史(毕竟我菜,所以题解十分易懂。。)

    我定睛一看,上一篇博客居然是去年省选写的...emmm我果然很懒.. 又是一年省选季,临死前订正一下去年的题吧.. 作为第一天30pts的滚粗选手,我去年并没有怎么思考这题.. 题意概括好麻烦,来来来 ...

  8. 7. Vulnerability exploitation tools (漏洞利用工具 11个)

    Metasploit于2004年发布时,将风暴带入了安全世界.它是开发,测试和使用漏洞利用代码的高级开源平台. 可以将有效载荷,编码器,无操作生成器和漏洞利用的可扩展模型集成在一起,使得Metaspl ...

  9. 第六节《Git克隆》

    本节学习如何使用git clone命令建立版本库克隆,以及如何使用git push和gitpull命令实现克隆之间的同步. Git的版本库目录和工作区在一起,因此存在一损俱损的问题,即如果删除一个项目 ...

  10. HD,3G视频数据中行号的插入方法---Verilog代码实现

    HD,3G视频数据中行号的插入方法---Verilog代码实现 行号的生成: `timescale 1ns / 1ps //////////////////////////////////////// ...