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

What is the method of managing the time and date of Linux system under systemd

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to manage the time and date of Linux system under systemd, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, people who have this need can learn, I hope you can gain something.

Timedatetl is a Linux application used to query and modify system time and configuration. It is part of systemd system services management and allows you to check and modify the configuration of the system clock.

Current time state of the system

To view the current date/time of the system, and to view the current system time configuration using commands with no parameters, you can do this:

# timedatectl

The input result looks like this:

modification date

To modify the system date, you can simply use the timedatetl command followed by a date in the format Y-MM-DD, where YYYY stands for year, MM stands for 2-digit month, and DD stands for 2-digit day. For example, if you want to change the date to February 4, 2015, you should use the following command:

# timedatectl 2015-02-04

modification time

To change the time, you can use the tool in the same way, but in the format HH:MM:SS, where HH stands for 24-hour clock, MM stands for minutes, and SS stands for seconds. To set the current time to 22:04:43, use the following command:

# timedatectl 22:04:43

modified the time zone

Setting the correct time zone is key to keeping time synchronized, especially if you are using NTP. First of all, you should use the list-timezones option to list the available time zones in your region. You can also use grep and more to make the format easier to read:

# timedatectl list-timezones | grep America | more

This will display a simple scrolling list format.

After that, you will know how to name the time zone you want to set, and then modify it using the following command:

# timedatectl set-timezone America/Los_Angeles

Set local clock

A real-time clock (RTC), often referred to as a hardware clock, is completely independent of the current state of the operating system and can even work when the computer is turned off. You can configure the system to use UTC or local time to correct RTC. Note that correcting RTC using local time zones is not perfectly supported, and there may be many problems due to time zone changes and daylight saving time adjustments. If possible, correct RTC in UTC mode. The only problem with this approach is that other operating systems may not fully support it (if you run two operating systems on the same machine).

To correct RTC using UTC mode, use the following command:

# timedatectl set-local-rtc 0

Using local time correction, use:

# timedatectl set-local-rtc 1

Set NTP synchronization

Network Time Protocol (NTP) is a network protocol for clock synchronization between packet-switched, variable-data-latency computer systems. NTP is designed to synchronize all participating computers using a few milliseconds of Coordinated Universal Time (UTC). If you wish to set NTP synchronization, you can use the set-ntp option setting. Use "no" to turn off NTP synchronization and "yes" to turn it on.

#timedatetl set-ntp yes Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report