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. LeetCode 34 - 在排序数组中查找元素的第一个和最后一个位置 - [二分][lower_bound和upper_bound]

    给定一个按照升序排列的整数数组 nums,和一个目标值 target.找出给定目标值在数组中的开始位置和结束位置. 你的算法时间复杂度必须是 O(log n) 级别. 如果数组中不存在目标值,返回 [ ...

  2. js常用正则表达式判断

    1.判断IP:端口 <html> <head> </head> <body> ip:port<input type="" na ...

  3. jmeter数据库连接配置

    一.实际试过的mysql配置 1.导入一个JDBC jar包(我是直接把jar包放在了jmeter的lib目录),包:mysql-connector-java-5.1.7-bin.jar 2.设置JD ...

  4. 一个人工智能教程,教案接地气、限制级。 http://www.captainbed.net

    一个人工智能教程,教案接地气.限制级. http://www.captainbed.net https://open.weibo.com/

  5. mybatis模糊查询

    今天遇到一个模糊查询的问题,需求是:根据传入的时间查询当天的所有数据,解决办法是使用$或者contact,具体sql模拟如下: select * from table_name where creat ...

  6. Spring Boot 国际化及点击链接跳转国家语言

    一.国际化 在SpringBoot中已经自动帮我们配置管理国际化资源的组件,所以我们只需要编写代码就可. @Bean @ConfigurationProperties(prefix = "s ...

  7. mac电脑安装wxPython2.8.12.1不成功怎么办 , Could not find a version that satisfies the requirement 2.8.12.1

    目的:robotframe-ride用于接口测试 遇到的问题: 1.mac终端pip安装robotframework-ride后 pip install robotframework-ride (pi ...

  8. Cocos Creater 监听程序到后台和重新到前台

    cocos creator前后台切换当玩家在玩游戏时,突然接了一个电话,此时游戏会被切到后台待机,所有的声音播放都会停止,等打完电话,回到游戏,游戏又会被切回前台来,需要手动播放声音.可使用如下代码 ...

  9. Go 初体验 - 错误与异常处理 - recover和panic

    先看代码: 输出: 内建函数panic可以让我们人为地产生一个运行时恐慌.不过,这种致命错误是可以被恢复的.在Go语言中,内建函数recover就可以做到这一点. 实际上,内建函数panic和reco ...

  10. Docker容器和本机之间的文件传输

    docker cp 本地文件路径 ID全称:容器路径