Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the time zone under Linux

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to change the time zone under Linux, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

Using the correct time zone is essential for many system-related tasks and processes. For example, cron daemons use the system time zone to perform cron tasks, and timestamps in log files are also based on the system time zone.

Check the current time zone

Timedatetl is a command-line utility that allows you to view and change the time and date of your system.

[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

change the time zone

Before you can change the time zone, you need to find out the name of the time zone you want to use. To list all available time zones, use the following command:

[root@localhost ~]# timedatectl list-timezones…Asia/SamarkandAsia/SeoulAsia/ShanghaiAsia/SingaporeAsia/Srednekolymsk…

Then use the set-timezone option to change the time zone, for example to Europe/Berlin:

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

Change the time zone using the way links are created

If you are running an older version of Centos, such as a version prior to Centos6, and the timedatetl command does not exist on your system, you can change the time zone by linking the/etc/localtime symbol to the time zone file in the/usr/share/zoneinfo directory.

Check out the time zone file under/usr/share/zoninfo,

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

Now replace the time zone file.

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

You can see that it has switched to CST China Standard Time.

About "how to change the time zone under Linux" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report