instant.now时区不正确_Centos8如何更改时区
生活随笔
收集整理的這篇文章主要介紹了
instant.now时区不正确_Centos8如何更改时区
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
對于許多與系統相關的任務和進程,使用正確的時區是必不可少的。例如,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更改時區
在更改時區之前,您需要找出要使用的時區名稱。要列出所有可用時區,請使用下面的命令:
[root@localhost ~]# timedatectl list-timezones…Asia/SamarkandAsia/SeoulAsia/ShanghaiAsia/SingaporeAsia/Srednekolymsk…然后使用set-timezone選項更改時區,比如更改為Europe/Berlin:
[root@localhost ~]# timedatectl set-timezone Europe/Berlin使用創建鏈接的方式更改時區
如果運行的是舊版本的Centos,比如Centos6之前的版本,并且系統上不存在timedatectl命令,則可以通過將/etc/localtime符號鏈接到/usr/share/zoneinfo目錄中的時區文件來更改時區。
查看一下/usr/share/zoninfo下面的時區文件,
[root@localhost ~]# ls /usr/share/zoneinfo/[root@localhost ~]# ls /usr/share/zoneinfo/Asia/現在替換時區文件。
[root@localhost ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime[root@localhost ~]# dateTue Mar 31 16:53:59 CST 2020可以看到已經切換到了CST中國標準時間
總結
在本文中,使用了兩種方式修改時區。一種是使用timedatectl,另一種方式使用創建鏈接的方式。
source : https://www.linuxprobe.com/centos8-change-timezone.html
總結
以上是生活随笔為你收集整理的instant.now时区不正确_Centos8如何更改时区的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mongotemplate 查list_
- 下一篇: mysql router安装教程_MyS