• linux时区


    1. UTC时区切换到CST 时区
    # echo "export TZ='Asia/Shanghai'" >> /etc/profile
    # cat /etc/profile |grep TZ
    # source /etc/profile
    # date -R
    # date
    Sat Aug 19 17:03:17 CST 2017

    2.修改时区

    时区设置用tzselect 命令来实现。但是通过tzselect命令设置TZ这个环境变量来选择的时区,需要将变量添加到.profile文件中。(/etc/profile)

    一、tzselect命令执行

    执行tzselect命令 --> 选择Asia --> 选择China --> 选择east China - Beijing, Guangdong, Shanghai, etc-->然后输入1。
    执行完tzselect命令选择时区后,时区并没有更改,只是在命令最后提示你可以执行 TZ=’Asia/Shanghai’; export TZ 并将这行命令添加到.profile中,然后退出并重新登录。

    二、修改配置文件来修改时区

    [root@linux-node ~]# echo "ZONE=Asia/Shanghai" >> /etc/sysconfig/clock
    [root@linux-node ~]# rm -f /etc/localtime
    #链接到上海时区文件
    [root@linux-node ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    执行完上述过程后,重启机器,即可看到时区已经更改。

    备注:

    在centos7中设置时区的命令可以通过 timedatectl 命令来实现
    [root@linux-node ~]# timedatectl set-timezone Asia/Shanghai

    相关链接:

    https://www.cnblogs.com/ibnode/p/3573302.html

  • 相关阅读:
    MonoRail学习-介绍篇(一)
    使用"_svn"替代".svn"的转换脚本
    Silverlight 4之ComboBox用法
    MD5 Algorithm
    子集算法的一个简单实现
    搜狗浏览器2.0正式版使用体验
    我做的抓屏软件
    WPF version of IPMessager
    Base64 Encode Decode Algorithm
    Origami Art
  • 原文地址:https://www.cnblogs.com/yinfutao/p/10558813.html
Copyright © 2020-2023  润新知