centos 7 时钟配置:

timedatectl 命令:

[root@localhost ~]# 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
[root@localhost ~]#

1.显示当前系统的时间和日期时区信息:

[root@localhost ~]# timedatectl
Local time: 四 -- :: CST
Universal time: 四 -- :: UTC
RTC time: 四 -- ::
Time zone: Asia/Shanghai (CST, +)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost ~]#

2.根据地址位置查询当前可用的时区设置:

root@localhost ~]# timedatectl list-timezones |grep 'Asia/S'
Asia/Sakhalin
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Srednekolymsk
[root@localhost ~]#

3.在Linux系统中设置北京时区:

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

4.设置时间

[root@localhost ~]# timedatectl set-time '2019-04-04 14:59'

5.hwclock

hwclock
硬件时钟,顾名思义,这个时间时存储在服务器主板上的时钟。硬件时钟存储的值包括:年、月、日、时、分、秒。不存储时间标准、本地时间、UTC、DST。这些设置存放在/etc/adjtime中,当我们修改时间设置(包括手动设置和自动同步)时该文件被创建。在RHEL6或CentOS6系统中,系统每次关机或重启都会自动执行这个命令。在RHEL7或CentOS7中,当系统时间向NTP服务器或PTP服务器同步时间后,每隔11分钟内核自动同步硬件时钟到系统时钟。
(1)显示硬件时钟。
[root@localhost ~]# hwclock
2019年04月04日 星期四 14时17分03秒 -0.400305 秒
[root@localhost ~]#

( 2 )将硬件时钟同步给系统时钟。

   -s和–hctosys效果是一样的。

root@localhost ~]# hwclock --systohc
[root@localhost ~]# hwclock -s
[root@localhost ~]# hwclock
2019年04月04日 星期四 15时05分01秒 -0.319360 秒
[root@localhost ~]#

  ( 3 ) 将系统时间写入硬件时钟

[root@localhost ~]# hwclock -w

6.crontab 定时执行时间同步

min hour dayofmonth month dayofweek command

minute: 表示分钟,可以是从0到59之间的任何整数。

hour:表示小时,可以是从0到23之间的任何整数。

day:表示日期,可以是从1到31之间的任何整数。

month:表示月份,可以是从1到12之间的任何整数。

week:表示星期几,可以是从0到7之间的任何整数,这里的0或7代表星期日。

command:要执行的命令,可以是系统命令,也可以是自己编写的脚本文件。

centos 时钟配置的更多相关文章

  1. Centos网络配置

    网上搜索:centos网络配置的方法,主要包括dns.网关.IP地址,主要是配置resolv.conf\network\ifcfg-eth0这些网络配置文件. 稍后我会就centos7的网络配置进行实 ...

  2. 阿里云服务器Linux CentOS安装配置(零)目录

    阿里云服务器Linux CentOS安装配置(零)目录 阿里云服务器Linux CentOS安装配置(一)购买阿里云服务器 阿里云服务器Linux CentOS安装配置(二)yum安装svn 阿里云服 ...

  3. 阿里云服务器Linux CentOS安装配置(九)shell编译、打包、部署

    阿里云服务器Linux CentOS安装配置(九)shell编译.打包.部署 1.查询当前目录以及子目录下所有的java文件,并显示查询结果 find . -name *.java -type f - ...

  4. 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定

    阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...

  5. 阿里云服务器Linux CentOS安装配置(七)域名解析

    阿里云服务器Linux CentOS安装配置(七)域名解析 1.购买域名 登录阿里云,左侧菜单点击[域名],然后[域名注册],完成域名购买.(一般首年45元) 2.添加域名解析 在域名列表里点击你的域 ...

  6. 阿里云服务器Linux CentOS安装配置(六)resin多端口配置、安装、部署

    阿里云服务器Linux CentOS安装配置(六)resin多端口配置.安装.部署 1.下载resin包 http://125.39.66.162/files/2183000003E08525/cau ...

  7. 阿里云服务器Linux CentOS安装配置(五)jetty配置、部署

    阿里云服务器Linux CentOS安装配置(五)jetty配置.部署 1.官网下载jetty:wget http://repo1.maven.org/maven2/org/eclipse/jetty ...

  8. 阿里云服务器Linux CentOS安装配置(四)yum安装tomcat

    阿里云服务器Linux CentOS安装配置(四)yum安装tomcat 1.yum -y install tomcat  执行命令后,会帮你把jdk也安装好 2.tomcat安装目录:/var/li ...

  9. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql

    阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...

随机推荐

  1. [JAVA] TicTacToe实现Socket通信(一)

    先来两张预览,大家可以试试jar包了,有什么问题评论哈,过两天贴代码 jar包这里下载 https://github.com/Andy-ZYA/TicTacToe_JAVA_Socket_Swing

  2. PHP算法学习(2) 轮训加权算法

    2019年1月8日16:10:51 svn地址:svn://gitee.com/zxadmin/live_z    代码在code里面 <?php /* * 加权轮训算法 * * * $arr ...

  3. python基础2 数据类型、数据拼接、数据转换

    一.数据类型 1.字符串 字符串英文string,简写str,只要是被[单/双/三引号]这层皮括起来的内容,不论那个内容是中文.英文.数字甚至火星文.只要是被括起来的,就表示是字符串类型 如:prin ...

  4. c++ 第一次实验

    实验内容: 2-28:实现一个简单的菜单程序,运行时显示“Menu:A(dd) D(elete) S(ort) Q(uit),Selete one:”提示用户输入.A表示增加,D表示删除, S表示排序 ...

  5. 记录一个bootstrap惨痛的错误

    记录一个bootstrap的错误,这个错误因为我删除了一个class就导致了页面上显示的错误,这是一个惨痛的教训,特此记录,提醒自己在做前端的修改时,一定要慎之又慎.如果真的要做改动,改完之后也要测一 ...

  6. 彻底清空SharePoint回收站(仅限IE)

    1.导航到回收站页面2.F12,在控制台输入javascript:emptyItems()3.回车 4.点击确定即可 注意:这种方法可能只适用于Internet Explorer

  7. 聚合函数对NULL统计

    Table ID Amount Number 1 28.26 NULL 2 NULL NULL 3 NULL NULL SQL SELECT SUM(Amount),SUM(Number),COUNT ...

  8. MySQL主从复制延迟的问题 #M1002#

    MySQL主从复制延迟的问题 #M1002# https://mp.weixin.qq.com/s/NwFGER-qn2xQ5TnG-php1Q 更为糟糕的是,MySQL主从复制在大事务下的延迟.同样 ...

  9. Java 数据库程序设计

    数据库基础 目前,大多数数据库系统都是关系数据库系统(relational database system).该数据库系统是基于关系数据模型的,这个模型有三个要素:结构.完整性和语言 结构(struc ...

  10. python装饰器扩展之functools.wraps

    我们知道函数被装饰器,装饰后,所有的属性,以及内置函数就失效了. 原因是函数类型变成了warpper类型 示例1:不带wraps装饰器示例 def warfunc(func): def warpper ...