How to manage the time and date of Linux systems under SYSTEMD

Source: Internet
Author: User
Tags time zones local time time and date timezones

Timedatectl is a Linux application used to query and modify system time and configuration. It is part of the SYSTEMD system service management and allows you to check and modify the configuration of the system clock.

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

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 without any parameters, you can:

# Timedatectl

The result of the input is like this:

Date Modified

To modify the system date, you can simply use Timedatectl to set the time command, followed by the YYYY-MM-DD format date, yyyy for the year, MM for the 2-digit month, and DD for the 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 modify the time, you can use the tool in the same way, but in the format hh:mm:ss,hh represents a 24-hour clock, MM for minutes, and SS for seconds. To set the current time to 22:04:43, use the following command:

Timedatectl:  :
Modify Time Zone

Setting the correct time zone is the key to keeping time synchronized, especially when you are synchronizing using the NTP protocol. First, you should use the List-timezones option to list the available time zones in your area, or you can 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'll know how the time zone you want to set is named, and then use the following command to modify it:

Set-timezone America/los_angeles
Set the 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 shuts down. You can configure the system to use international time (UTC) or local time to correct the RTC. Note that there is no perfect support for correcting RTC using the local time zone, and there may be many problems due to time zone changes and daylight saving adjustment. If possible, correct the RTC in UTC mode. The only problem with this approach is that other operating systems may not fully support it (if you run 2 operating systems on the same machine).

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

set-0

Using local time correction, use:

set-1
Setting up NTP synchronization

Network Time Protocol (NTP) is a network protocol for clock synchronization between computer systems with packet switching and variable data delay. NTP is designed to synchronize all participating computers with a few milliseconds of Coordinated Universal Time (UTC). If you want to set up NTP synchronization, you can use the SET-NTP option setting. Use "No" to turn off NTP synchronization and use "yes" to turn it on.

SET-NTP Yes
    • Related articles recommended:
    • Migrating from Initscripts to Systemd
    • Early adopters: The new network connection management tool SYSTEMD-NETWORKD
    • A good crontab tutorial
    • This article from: Hobby Linux Technology Network
    • This article link: http://www.ahlinux.com/start/base/9473.html

How to manage the time and date of Linux systems under SYSTEMD

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.