Use TIMEDATECTL command time time zone operation under Linux detailed

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

The Timedatectl command is a new tool for Rhel/centos 7 and a distributed system based on Fedora 21+, as part of the SYSTEMD system and service Manager, Instead of the old traditional date command used in the Linux distributed system-based Sysvinit daemon.

The TIMEDATECTL command can query and change the system clock and settings, and you can use this command to set or change the current date, time, and time zone, or to synchronize the automatic system clock with the remote NTP server.

In this tutorial, I'm going to talk about how to manage time on your Linux system by using NTP, which uses the TIMEDATECTL command from the terminal, to set the date, times, timezone, and synchronize. Keeping your Linux server or system in the right time is a good practice and it has the following advantages:

1) Maintain the timely operation of the system tasks, because most of the tasks in Linux are controlled by time.

2) record the correct time for events and other information on the system.

How to find and set the Linux local time zone

1. To display the current time and date of the system, use the TIMEDATECTL command on the command line as follows:

# TIMEDATECTL Status

In the example above, the RTC time is the hardware clock.

2. The time on the Linux system is always set by timezone on the system, to view the current timezone, do as follows:

# Timedatectl or# Timedatectl | grep time

3. To view all available time zones, run the following command:

# Timedatectl List-timezones

4. To locate the local time zone according to the geographic location, run the following command:

# Timedatectl List-timezones | Egrep-o ' asia/b.* ' # timedatectl List-timezones | Egrep-o "europe/l.*" # Timedatectl List-timezones | Egrep-o "America/n.*"

5. To set the local time zone in Linux, use the set-timezone switch as shown below.

# timedatectl Set-timezone "Asia/kolkata"

It is recommended to use and set Coordinated Universal time, that is UTC.

# Timedatectl Set-timezone UTC

You need to enter the correct time zone, and the error may occur when you change the time zone. In the following example, the time zone "Asia/kalkata" is incorrect, resulting in an error.

How to set the time and date in Linux

You can use the TIMEDATECTL command to set the date and time on the system as follows:

6. Set the time in Linux. To set the time only, we can use the set-time switch and the time format of HH:MM:SS (hours, minutes, seconds).

# Timedatectl Set-time 15:58:30

7, set the date in Linux. To set the date only, we can use the set-time switch as well as the date format of the YY:MM:DD (year, month, day).

# Timedatectl Set-time 20151120

8. Set the date and time:

# timedatectl Set-time ' 16:10:40 2015-11-20 '

How to find and set hardware clocks in Linux

9. To set the hardware clock to reconcile Universal Time, UTC, you can use the SET-LOCAL-RTC boolean-value option as follows:

First determine if your hardware clock is set to the local time zone:

# Timedatectl | grep Local

Set your hardware clock to the local time zone:

# Timedatectl SET-LOCAL-RTC 1

Set your hardware clock to Coordinated Universal Time (UTC):

# timedatectl SET-LOCAL-RTC 0

Synchronizing the Linux system clock to a remote NTP server

NTP, network time Protocol, is an Internet protocol that synchronizes the system clock between computers. The Timedatectl utility can automatically synchronize your Linux system clock to a remote server using NTP.

Note that you must install NTP on the system to enable automatic time synchronization with the NTP server.

To start automatic time synchronization to a remote NTP server, type the following command at the terminal.

# Timedatectl SET-NTP True

To disable NTP time synchronization, type the following command at the terminal.

# Timedatectl SET-NTP False

Original link: http://www.codeceo.com/article/linux-timedatectl-set-time.html

How to Set time, Timezone and Synchronize System Clock Using timedatectl Command

Using timedatectl command time time zone operation under Linux

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.