How to set or modify the time zone in CentOS 8

Using the correct time zone is essential for many system-related tasks and processes. For example: the cron daemon uses the system time zone to execute cron tasks, and the timestamp in the log file is also based on the system time zone.

On CentOS, the system time zone is set during the installation process, and it can be easily modified later.

This article describes how to set or modify the time zone on CentOS 8 system.

1. Check the current time zone##

timedatectl is a command line tool that allows you to view and modify the system time and date. It can be used in all modern systemd-based Linux systems:

timedatectl

The output shows the time zone of the system. In this example, the time zone is set to UTC:

  Local time: Sat 2020-03-2121:30:22 UTC
   Universal time: Sat 2020-03-2121:30:22 UTC
     RTC time: Sat 2020-03-2121:30:22
    Time zone:UTC(UTC,+0000)
System clock synchronized: yes
    NTP service: active
   RTC in local TZ: no

If you get a warning saying, "The system is configured to read the RTC time in the local time zone.", run the following command to use RTC in UTC:

timedatectl

The system time zone is configured through the link file /etc/localtime, which points to a binary time zone identification file in the /usr/share/zoneinfo directory. Another way to check the time zone is to display the actual path the linked file points to, using the ls command:

ls -l /etc/localtime
lrwxrwxrwx.1 root root 23 Nov 2123:30/etc/localtime ->/usr/share/zoneinfo/UTC

Two, modify the time zone in CentOS##

When changing the time zone, you will need to find a long name for the time zone you want to use. The time zone usually uses the "region/city" format.

To list all available time zones, run the timedatectl command and add the list-timezones option:

timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

Once you have identified which time zone is ready to describe your location, as root or another user with sudo privileges, run the following command:

sudo timedatectl set-timezone your_time_zone

For example, to set the system time zone to America/Toronto:

sudo timedatectl set-timezone America/Toronto

Run the timedatectl command to verify the modification:

timedatectl
    Local time: Sat 2020-03-2117:43:39 EDT
   Universal time: Sat 2020-03-2121:43:39 UTC
     RTC time: Sat 2020-03-2121:43:40
    Time zone: America/Toronto(EDT,-0400)
System clock synchronized: yes
    NTP service: active
   RTC in local TZ: no

3. Modify the time zone by creating a link##

If you are running an older CentOS version, and timedatectl is not available on your system, you can modify the time zone link file /etc/localtime to the time zone under the directory /usr/share/zoneinfo File to modify the time zone.

Identify the time zone you want to configure, and create a link file:

sudo ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime

Verify the modification by listing the /etc/localtime file or triggering the timedatectl or date command:

date
Sat Mar 2117:46:10 EDT 2020

Four, summary##

We have shown how to modify the time zone of your CentOS system.

Recommended Posts

How to set or modify the time zone in CentOS 8
How to set or modify the time zone on Ubuntu 20.04
How to modify time zone and time in ubuntu
How to modify the CentOS server time to Beijing time
How to modify time zone and time in ubuntu system
How to modify the hostname on CentOS 8
How to change the CentOS server time to Beijing time
Centos system modify time zone
How to configure NTP to join the NTP pool project in CentOS
How to install HDP2.6 in Centos7.2
Modify CentOS server time to Beijing time
How to set up the Nginx server configuration block on CentOS 8
How to install Android SDK in centos7
How to set static IP in ubuntu14.04
How to modify software source in Ubuntu 7.10
How to learn the Python time module
How to modify the hostname on Ubuntu 20.04
How to set time zone and NTP synchronization on Ubuntu 14.04 [Quick Start]
How to use the round function in python
How to use the zip function in Python
How to use the format function in python
How to open the ubuntu system in win10
How to set code auto prompt in python
How to quickly modify root password under CentOS8
How to set up time synchronization on Ubuntu 18.04
How to install the downloaded module in python
How to install php7.3 in centos8 custom directory
Centos7 modify the system language to simplified Chinese
How to create a CentOS virtual machine in VMware
How to understand the introduction of packages in Python
How to create a CentOS virtual machine in VMware
Example of how to modify ip address in Ubuntu20.04
How to control the ubuntu system in win10 through ssh
How to set up an Apache virtual host on CentOS 7
How to find the area of a circle in python
Detailed steps to automatically set the line number in ubuntu16.04
Set the network card to bridge mode under CentOS6.3 KVM
How to support TL-WDN7200H wireless USB network card in CentOS8?
Update gcc to 6.4.0 in centos
How to install JDK 13 in the Linux environment using compressed packages
How to install Helm in Ubuntu
How to install MySQL on CentOS 8
How to upgrade CentOS7 to CentOS8 (detailed steps)
How to use hanlp in ubuntu
How to install Memcached on CentOS 8
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to Update to gcc4.9.x on Centos7
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to wrap in python code
How to install Git on CentOS 8
How to save the python program
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8