zoukankan      html  css  js  c++  java
  • CentOS 8系统更改时钟时区

    对于许多与系统相关的任务和进程,使用正确的时区是必不可少的。例如,cron守护进程使用系统的时区执行cron作业,日志文件中的时间戳基于同一系统的时区。
    环境

    Centos8

    检查现在的时区

    timedatectl是一个命令行实用程序,允许您查看和更改系统的时间和日期。

    [root@localhost ~]# timedatectl 
                   Local time: Tue 2020-03-31 16:35:23 CST
               Universal time: Tue 2020-03-31 08:35:23 UTC
                     RTC time: Tue 2020-03-31 08:35:23
                    Time zone: Asia/Shanghai (CST, +0800)
    System clock synchronized: yes
                  NTP service: active
              RTC in local TZ: no
    

    Centos8如何更改时区Centos8如何更改时区

    更改时区

    在更改时区之前,您需要找出要使用的时区名称。要列出所有可用时区,请使用下面的命令

    [root@localhost ~]# timedatectl list-timezones
    …
    Asia/Samarkand
    Asia/Seoul
    Asia/Shanghai
    Asia/Singapore
    Asia/Srednekolymsk
    …
    

    然后使用set-timezone选项更改时区,比如更改为Europe/Berlin:

    [root@localhost ~]# timedatectl set-timezone Europe/Berlin
    

    Centos8如何更改时区Centos8如何更改时区

    使用创建链接的方式更改时区

    如果运行的是旧版本的Centos,比如Centos6之前的版本,并且系统上不存在timedatectl命令,则可以通过将/etc/localtime符号链接到/usr/share/zoneinfo目录中的时区文件来更改时区。

    查看一下/usr/share/zoninfo下面的时区文件,

    [root@localhost ~]# ls /usr/share/zoneinfo/
    [root@localhost ~]# ls /usr/share/zoneinfo/Asia/
    

    Centos8如何更改时区Centos8如何更改时区

    Centos8如何更改时区Centos8如何更改时区
    现在替换时区文件。

    [root@localhost ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    [root@localhost ~]# date
    Tue Mar 31 16:53:59 CST 2020
    

    可以看到已经切换到了CST中国标准时间

    总结

    在本文中,使用了两种方式修改时区。一种是使用timedatectl,另一种方式使用创建链接的方式。

  • 相关阅读:
    Python全栈开发之---mysql数据库
    python爬虫项目(scrapy-redis分布式爬取房天下租房信息)
    python多线程爬虫+批量下载斗图啦图片项目(关注、持续更新)
    python爬虫+数据可视化项目(关注、持续更新)
    超融合基本架构简单定义
    开启新生之路,,,学习网络
    Redhat7.2 ----team网卡绑定
    设计原则
    java应用程序的运行机制
    java三大版本和核心优势
  • 原文地址:https://www.cnblogs.com/linuxprobe/p/13276702.html
Copyright © 2011-2022 走看看