Get the App
SLTechnology News&Howtos  ›  Development  › 

How to quickly modify the time zone under CentOS

Shulou Source: shulou.com Published: 2022-06-01 16:31:04 10月02日 Update

This article mainly introduces the relevant knowledge of "how to quickly modify the time zone under CentOS". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to quickly modify the time zone under CentOS" can help you solve the problem.

Method 1: timedatectl set-timezone Asia/Shanghai# timedatectlWarning: Ignoring the TZ variable. Reading the system's time zone setting only.Local time: Mon 2016-11-21 01:52:42 ESTUniversal time: Mon 2016-11-21 06:52:42 UTCRTC time: Mon 2016-11-21 06:52:42Time zone: America/New_York (EST -0500) NTP enabled: n/aNTP synchronized: noRTC in local TZ: noDST active: noLast DST change: DST ended atSun 2016-11-06 01:59:59 EDTSun 2016-11-06 01:00:00 ESTNext DST change: DST begins (the clock jumps one hour forward) atSun 2017-03-12 01:59:59 ESTSun 2017-03-12 03:00:00 EDT

Set the time zone to CST (East 8)

# timedatectl set-timezone Asia/ShanghaiWarning: Ignoring the TZ variable. Reading the system's time zone setting only.Local time: Mon 2016-11-21 14:52:59 CSTUniversal time: Mon 2016-11-21 06:52:59 UTCRTC time: Mon 2016-11-21 06:52:59Time zone: Asia/Shanghai (CST, + 0800) NTP enabled: n/aNTP synchronized: noRTC in local TZ: noDST active: n/aNTP synchronized a [root@localhost ~] # method 2:TZ environment variable manner

Modify the. bash_profile in the user directory and append it to the end of the file:

TZ='Asia/Shanghai'; export TZ

After launching the login, log in again, and the date command can see the effect.

This is the end of the content about "how to quickly change the time zone under CentOS". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Time zone method knowledge industry login different practical content variables commands practicality actual effects files articles methods more end case environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker MySQL NVidia Apple