Linux时钟分为系统时钟(System Clock)和硬件(Real Time Clock,简称RTC)时钟。系统时钟是指当前Linux Kernel中的时钟,而硬件时钟则是主板上由电池供电的时钟,这个硬件时钟可以在BIOS中进行设置。当Linux启动时,硬件时钟会去读取系统时钟的设置,然后系统时钟就会独立于硬件运作。
  Linux中的所有命令(包括函数)都是采用的系统时钟设置。在Linux中,用于时钟查看和设置的命令主要有date、hwclock和clock。其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。

1、date
  查看系统时间
# date

  设置系统时间

# date --set "02/20/2014  16:50:00" (月/日/年 时:分:秒)

2、hwclock/clock

  查看硬件时间

# hwclock --show
或者
# clock --show

  设置硬件时间

# hwclock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)
或者
# clock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)

3、硬件时间和系统时间同步

  按照前面的说法,重新启动系统,硬件时间会读取系统时间,实现同步,但是在不重新启动的时候,需要用hwclock或clock命令实现同步。

  硬件时钟与系统时钟同步:# hwclock --hctosys(hc代表硬件时间,sys代表系统时间)或者# clock --hctosys

  系统时钟和硬件时钟同步:# hwclock --systohc或者# clock --systohc

4、时区设置

# tzselect

Please identify a location so that time zone rules can be set correctly.Please select a continent or ocean. ) Africa ) Americas ) Antarctica ) Arctic Ocean ) Asia ) Atlantic Ocean ) Australia ) Europe ) Indian Ocean10) Pacific Ocean11) none - I want to specify the time zone using the Posix TZ format.#? 输入5,亚洲

Please select a country. ) Afghanistan ) Israel ) Palestine ) Armenia ) Japan ) Philippines ) Azerbaijan ) Jordan ) Qatar ) Bahrain ) Kazakhstan ) Russia ) Bangladesh ) Korea (North) ) Saudi Arabia ) Bhutan ) Korea (South) ) Singapore ) Brunei ) Kuwait ) Sri Lanka ) Cambodia ) Kyrgyzstan ) Syria ) China ) Laos ) Taiwan10) Cyprus ) Lebanon ) Tajikistan11) East Timor ) Macau ) Thailand12) Georgia ) Malaysia ) Turkmenistan13) Hong Kong ) Mongolia ) United Arab Emirates14) India ) Myanmar (Burma) ) Uzbekistan15) Indonesia ) Nepal ) Vietnam16) Iran ) Oman ) Yemen17) Iraq ) Pakistan#? 输入9,中国

Please select one of the following time zone regions.) east China - Beijing, Guangdong, Shanghai, etc.) Heilongjiang3) central China - Gansu, Guizhou, Sichuan, Yunnan, etc.) Tibet & most of Xinjiang Uyghur5) southwest Xinjiang Uyghur#? 输入1,北京时间

The following information has been given:

China east China - Beijing, Guangdong, Shanghai, etc.

Therefore TZ="Asia/Shanghai" will be used.Local time is now: Fri Jul  :: CST .Universal Time is now: Fri Jul  :: UTC .Is the above information OK?) Yes2) No#? 输入1,确认

  除了使用tzselect命令修改时区外,还可以修改文件变更时区:

# vi /etc/sysconfig/clock ZONE=Asia/Shanghai(查/usr/share/zoneinfo下面的文件) UTC=false ARC=false 

# rm /etc/localtime 

# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
 

Linux系统时间设置(转载)的更多相关文章

  1. Linux 系统时间设置

    from:https://blog.csdn.net/yjh314/article/details/51669238 今早看到一台机器时间对不上,本以为系统时间与网络北京时间不同步,就在终端命令执行网 ...

  2. linux 系统时间 硬件时间

    Linux时钟分为系统时钟(System Clock)和硬件时钟(Real Time Clock,简称RTC).系统时钟是指当前Linux Kernel中的时钟:而硬件时钟则是主板上由电池供电的时钟, ...

  3. Linux系统时间的设置

    1. Linux系统时间的设置 在Linux中设置系统时间,可以用date命令: //查看时间[root@node1 ~]# dateTue Feb 25 20:15:18 CST 2014//修改时 ...

  4. Linux系统时间同步方法

    在Windwos中,系统时间的设置很简单,界面操作,通俗易懂,而且设置后,重启,关机都没关系.系统时间会自动保存在BIOS时钟里面,启动计算机的时候,系统会自动在BIOS里面取硬件时间,以保证时间的不 ...

  5. Linux系统时间同步方法小结

    在Windwos中,系统时间的设置很简单,界面操作,通俗易懂,而且设置后,重启,关机都没关系.系统时间会自动保存在BIOS时钟里面,启动计算机的时候,系统会自动在BIOS里面取硬件时间,以保证时间的不 ...

  6. Linux学习之十-Linux系统时间

    Linux系统时间 1.date命令用于查看以及修改Linux系统的时间,关于date命令的详细帮助文档如下 [root@localhost ~]# date --help Usage: date [ ...

  7. Linux的硬件时间、校正Linux系统时间及系统时间调用流程

    第一部分: 一)概述: 事实上在Linux中有两个时钟系统,分别是系统时间和硬件时间 UTC是协调世界时(Universal Time Coordinated)英文缩写,它比北京时间早8个小时.   ...

  8. 时间篇之linux系统时间和RTC时间

    一.linux系统下包含两个时间:系统时间(刚启动时读取的是rtc时间)和RTC时间. 一般情况下都会选择芯片上最高精度的定时器作为系统时间的定时基准,以避免在系统运行较长时间后出现大的时间偏移.特点 ...

  9. Linux_自动调整linux系统时间和时区与Internet时间同步

    调整linux系统时间和时区与Internet时间同步 一.修改时区:# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime修改为中国的东八区# v ...

随机推荐

  1. (转) A Survival Guide to a PhD

    A Survival Guide to a PhD Sep 7, 2016 This guide is patterned after my “Doing well in your courses”, ...

  2. CSS Position 定位属性介绍

    1.介绍 1.1 说明 Position 属性:规定元素的定位类型.即元素脱离文档流的布局,在页面的任意位置显示. 1.2 主要的值 ①absolute :绝对定位:脱离文档流的布局,遗留下来的空间由 ...

  3. Twitter 登录和分享

    继上面一片介绍了FaceBook的登录和分享,现在再来实现Twitter的登录和分享. 1.首先要说明的是,我没找到官方提供的SDK,查阅很多文章都提到了一个帮助实现的包Twitter4j.jar   ...

  4. python [吐槽]关于nan类型时遇到的问题

    今天在用写一段求和的代码时候,发现最后返回的是nan的结果,这段循环求和代码依次调用了三个函数,于是依次打印这三个函数的返回值,发现其中一个函数的返回值为nan,原来是因为这段函数里面没有相似的用户, ...

  5. 数据结构线性表(js实现)

    最近在复习数据结构的过程中,发现基本上数据结构都是用C来实现的,自己之前学习的时候也是用C去写的,由于目前对js更为熟悉一些,所以这里选择使用js去实现其中的某些算法和结构.实际上算法和语言关系不大, ...

  6. Jersey框架一:Jersey RESTful WebService框架简介

    Jersey系列文章: Jersey框架一:Jersey RESTful WebService框架简介 Jersey框架二:Jersey对JSON的支持 Jersey框架三:Jersey对HTTPS的 ...

  7. hadoop(四): 本地 hbase 集群配置 Azure Blob Storage

    基于 HDP2.4安装(五):集群及组件安装 创建的hadoop集群,修改默认配置,将hbase 存储配置为 Azure Blob Storage 目录: 简述 配置 验证 FAQ 简述: hadoo ...

  8. [nginx]Nginx禁止访问robots.txt防泄漏web目录

    关于robots.txt文件:搜索引擎通过一种程序robot(又称spider),自动访问互联网上的网页并获取网页信 息.您可以在您的网站中创建一个纯文本文件robots.txt,在这个文件中声明该网 ...

  9. CSS命名规则

    头:header  内容:content/container  尾:footer  导航:nav  侧栏:sidebar 栏目:column  页面外围控制整体布局宽度:wrapper  左右中:le ...

  10. nginx ssi 配置小细节(一)

    最近工作需要使用nginx的ssi (server side include)技术,在这里,将使用中的一点心得分享一下,也是一种备忘! 首先,nginx的ssi启用很简单,就只有三个最基本的指令: s ...