How to manage Linux system time and date in systemd

Source: Internet
Author: User
Tags comparison table time zones timezones

How to manage Linux system time and date in systemd

Timedatectl is a Linux application used to query and modify the system time and configuration. It is part of systemd System Service Management and allows you to check and modify system clock configurations.

In this article, we will cover all aspects of this small but important application.

Current System Time status

To view the current date/time of the system, and use a command without any parameters to view the current system time configuration, you can do this:

  1. # Timedatectl

The input result is as follows:

Modification date

To modify the system date, you can simply use timedatectl to set the time command, followed by the YYYY-MM-DD format of the date, YYYY represents the year, MM represents the two digits of the month, DD represents the day of two digits. For example, if you want to change the date to February 4, 2015, you should use the following command:

  1. # Timedatectl 2015-02-04
Modification time

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

  1. # Timedatectl 22:04:43
Modify Time Zone

Setting the correct time zone is the key to maintaining time synchronization, especially when you use the NTP protocol for synchronization. First, you should use the list-timezones option to list available time zones in your region. You can also use grep and more to make the format easier to read:

  1. # Timedatectl list-timezones | grep America | more

This will display a simple scrolling list format.

Then you will know how the time zone you want to set is named, and then use the following command to modify it:

  1. # Timedatectl set-timezone America/Los_Angeles
Set local clock

Real-time clock (RTC), usually called a hardware clock, is completely independent of the current operating system status and can even work when the computer is shut down. You can configure the system to use international Time (UTC) or local time to correct RTC. Note that using the local time zone to correct RTC is not fully supported, and there may be many problems caused by 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 ).

Use the following command to correct RTC in UTC mode:

  1. # Timedatectl set-local-rtc 0

Use local time correction, use:

  1. # Timedatectl set-local-rtc 1
Set NTP Synchronization

Network Time Protocol (NTP) is a network protocol for clock synchronization between computer systems with group switching and variable data latency. NTP is designed to use Coordinated Universal Time (UTC) in milliseconds to synchronize all participating computers. If you want to set NTP synchronization, you can use the set-ntp option. Use "no" to disable NTP synchronization and use "yes.

  1. # Timedatectl set-ntp yes

Linux boot mode: systemd upstart sysV

Why is systemd so quickly adopted?

Systemd and sysVinit Color comparison table

Linux Kernel EMD -- start/stop/restart the service in RHEL/CentOS 7

So useful! Run the systemd command to manage the Linux system!

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.