转载于:https://www.cnblogs.com/LouisZJ/p/8554991.html

[root@nginx ~]# timedatectl --help
timedatectl [OPTIONS...] COMMAND ...
Query or change system time and date settings. -h --help Show this help message
--version Show package version
--no-pager Do not pipe output into a pager
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
--adjust-system-clock Adjust system clock when changing local RTC mode Commands:
status Show current time settings
set-time TIME Set system time
set-timezone ZONE Set system time zone
list-timezones Show known time zones
set-local-rtc BOOL Control whether RTC is in local time
set-ntp BOOL Control whether NTP is enabled

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

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

设置当前时间:

timedatectl set-time HH:MM:SS

设置当前日期:

timedatectl set-time YYYY-MM-DD

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

timedatectl set-local-rtc boolean

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

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

设置时区:

查看所有的时区:

timedatectl list-timezones

设置时区

timedatectl set-timezone time_zone

远程NTP服务器同步

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

timedatectl set-ntp boolean

这里的boolean是yes或者no

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

查看系统时间

[root@nginx ~]# date
2018年 03月 13日 星期二 10:58:41 CST

查看硬件时间

[root@nginx ~]# hwclock --show
2018年03月13日 星期二 11时00分16秒 -0.086030 秒

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

更新时区

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

更新日期

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

更新时间

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

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

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

将日期写入CMOS

[root@localhost ~]# clock –w
 
 
												

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. vue-cli搭建项目模拟后台接口数据,webpack-dev-conf.js文件配置

    webpack.dev.conf.js 首先第一步 const express = require('express');const app = express();var appData = req ...

  2. C++中的基础特性:封装,继承,多态

    抽象: 要将现实中的一个具体事务,变成C++中的一个类,例如将现实中的汽车变成代码中的car类.完成这个过程就需要 抽象 这一基本手段. 抽象是指 对具体问题(对象)进行分析概括,找出该类对象的公共性 ...

  3. oracle 常见查询题

    查询比本部门平均薪水高的员工信息 解法一: select d.deptno,e.empno,e.ename,e.sal,d.avgsal from emp e, (select deptno,avg( ...

  4. 16.python-I/O模型

    一.事件驱动模型1.什么是事件驱动模型:本身是一种编程范式,这里程序的执行是由外部事件来决定的.它的特点是包含一个事件循环,当外部事件发生时使用回调机制来触发相应的处理.常见的编程范式(单线程)同步以 ...

  5. Eclipse导入已有的项目后项目报错的解决办法

    第一种:jsp报错 选择windows-->preference-->列表找到Validation-->点击Disable All ->> Apply ->> ...

  6. Linux 系统的总管 Systemd

    目录 1. init的进化,全功能的Systemd 2 1.1 Linux系统中,init主要有3个版本 2 1.2 比较传统的init程序,Systemd的特点有: 2 1.3 Systemd Jo ...

  7. SDL中 so库的使用

    用到的项目:Tocy-Android-SDLv2 JAVA层:只有一个 SDLActivity.java 路径\Android-SDLv2\src\org\libsdl\app 项目简单分析: 默认在 ...

  8. admin-2

    Linux是一种服务器操作系统 操作系统:一堆软件的集合,可以让计算机硬件正常工作 • UNIX诞生,1970-1-1(Linux系统时间的起点) • Linux之父,Linus Torwalds 内 ...

  9. Yii2 设计模式——Yii2 中用到哪些设计模式?

    Yii 2 设计模式“包含了两个方面的内容:1. 设计模式,2. Yii 2 框架. <设计模式>一书虽然以JAVA语言来表达设计模式的思想,但是设计模式远不限制于某一种特定的语言,而是在 ...

  10. QT心电图设计

    不需要别的UI设置,直接放在QT文件中即可 #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #includ ...