zoukankan      html  css  js  c++  java
  • Linux系统更改时区

    更改时区

    在给国外伙伴部署机器的时候,经常会碰到需要给Linux修改时区的情况:

    这里例举几个方式:

    1:覆盖/etc/localtime文件内容

    /usr/share/zoneinfo/ 下面都是对应的洲以及其对应的时区,如果我们需要修改时区为Shanghai的话,执行下面的操作:

    [root@VM-75-60 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    cp: overwrite `/etc/localtime'? y
    [root@VM-75-60 ~]#

    检测是否生效:

    [root@VM-75-60 ~]# date -R
    Fri, 24 Jul 2020 22:59:39 +0800

    最后的参数‘+0800’就表示东八区!

    2:tzselect指令

    [root@VM-75-60 ~]# tzselect
    Please identify a location so that time zone rules can be set correctly.
    Please select a continent or ocean.
     1) Africa
     2) Americas
     3) Antarctica
     4) Arctic Ocean
     5) Asia
     6) Atlantic Ocean
     7) Australia
     8) Europe
     9) Indian Ocean
    10) Pacific Ocean
    11) none - I want to specify the time zone using the Posix TZ format.

    通过交互式,利用首位的数字去选择你想要选择的时区。

    但这里tzselect并不能真正设置当前机器的时区,他只是一个向导,让你找到你想要找到的地区时区表示方式以及如何让它生效,指令在最后给出了:

    You can make this change permanent for yourself by appending the line
            TZ='Asia/Shanghai'; export TZ
    to the file '.profile' in your home directory; then log out and log in again.

    你看,他让你编辑.profile,设置个TZ变量。。。

    第一种方法直接cp覆盖不香吗?

    注意:升级了glibc之后的机器,crond和rsyslog等程序的读取时间都会变成新的glibc下的localtime,因此需要重新做软连接,把/etc/localtime软连接到新的glibc下的localtime

  • 相关阅读:
    redux-simple 简化版的redux
    react服务端渲染(同构)
    使用systemd管理程序进程
    使用Dockerfile构建镜像
    centos7使用supermin制作centos7的docker镜像包
    DNS-dnsmasq安装配置
    kubernetes-部署(单机,使用证书)
    DNS-bind+namedmanager安装
    python3第一个脚本(hello world!)
    Python3 基础语法
  • 原文地址:https://www.cnblogs.com/storyawine/p/13357729.html
Copyright © 2011-2022 走看看