CentOS 7 修改时区

本文转载至:http://mathslinux.org/?p=637

Linux 系统(我特指发行版, 没说内核) 下大部分软件的风格就是不会仔细去考虑向后 的兼容性, 比如你上个版本能用这种程序配置, 没准到了下一个版本, 该程序已经不见了. 比如 sysvinit 这种东西.

设置时区同样, 在 CentOS 7 中, 引入了一个叫 timedatectl 的设置设置程序.

用法很简单:

<span style="color: rgb(102, 102, 102);"><em># timedatectl # 查看系统时间方面的各种状态</em></span>
      Local time: 四 2014-12-25 10:52:10 CST
  Universal time: 四 2014-12-25 02:52:10 UTC
        RTC time: 四 2014-12-25 02:52:10
        Timezone: Asia<span style="font-weight: bold;">/</span>Shanghai <span style="color: rgb(122, 8, 116);"><strong>(</strong></span>CST, +0800<span style="color: rgb(122, 8, 116);"><strong>)</strong></span>
     NTP enabled: <span style="color: rgb(194, 12, 185);"><strong>yes</strong></span>
NTP synchronized: <span style="color: rgb(194, 12, 185);"><strong>yes</strong></span>
 RTC <span style="font-weight: bold;">in</span> <span style="color: rgb(122, 8, 116);"><strong>local</strong></span> TZ: no
      DST active: n<span style="font-weight: bold;">/</span>a
<span style="color: rgb(102, 102, 102);"># </span>timedatectl list-timezones <span style="color: rgb(102, 102, 102);"><em># 列出所有时区</em></span>
<span style="color: rgb(102, 102, 102);"># </span>timedatectl set-local-rtc 1 <span style="color: rgb(102, 102, 102);"><em># 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间</em></span>
<span style="color: rgb(102, 102, 102);"># </span>timedatectl set-timezone Asia<span style="font-weight: bold;">/</span>Shanghai <span style="color: rgb(102, 102, 102);"><em># 设置系统时区为上海</em></span>

其实不考虑各个发行版的差异化, 从更底层出发的话, 修改时间时区比想象中要简单:

<span style="color: rgb(102, 102, 102);"># </span><span style="color: rgb(194, 12, 185);"><strong>cp</strong></span> <span style="font-weight: bold;">/</span>usr<span style="font-weight: bold;">/</span>share<span style="font-weight: bold;">/</span>zoneinfo<span style="font-weight: bold;">/</span>Asia<span style="font-weight: bold;">/</span>Shanghai <span style="font-weight: bold;">/</span>etc<span style="font-weight: bold;">/</span>localtime
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值