Chapter 3. Configuring the Date and Time
- A real-time clock (RTC), commonly referred to as a hardware clock, (typically an integrated circuit on the system board) that is completely independent of the current state of the operating system and runs even when the computer is shut down.
- A system clock, also known as a software clock, that is maintained by the kernel and its initial value is based on the real-time clock. Once the system is booted and the system clock is initialized, the system clock is completely independent of the real-time clock.
timedatectlutility, which is new in Red Hat Enterprise Linux 7 and is part of
systemd; the traditional
datecommand; and the
hwclockutility for accessing the hardware clock.
3.1. Using the
systemdsystem and service manager and allows you to review and change the configuration of the system clock. You can use this tool to change the current date and time, set the time zone, or enable automatic synchronization of the system clock with a remote server.
3.1.1. Displaying the Current Date and Time
timedatectlcommand with no additional command line options:
NTP) configuration, and additional information related to DST.
Example 3.1. Displaying the Current Date and Time
timedatectlcommand on a system that does not use
NTPto synchronize the system clock with a remote server:
timedatectlLocal time: Mon 2016-09-16 19:30:24 CEST Universal time: Mon 2016-09-16 17:30:24 UTC Timezone: Europe/Prague (CEST, +0200) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2016-03-31 01:59:59 CET Sun 2016-03-31 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2016-10-27 02:59:59 CEST Sun 2016-10-27 02:00:00 CET
ntpdwill not be immediately noticed by
timedatectl. If changes to the configuration or status of these tools is made, enter the following command:
systemctl restart systemd-timedated.service
3.1.2. Changing the Current Time
NTPservice is enabled. See Section 3.1.5, “Synchronizing the System Clock with a Remote Server” to temporally disable the service.
Example 3.2. Changing the Current Time
timedatectl set-time 23:26:00
timedatectlcommand with the
1). To configure the system to use UTC, replace boolean with
0). The default option is
3.1.3. Changing the Current Date
Example 3.3. Changing the Current Date
timedatectl set-time 2017-06-02 23:26:00
3.1.4. Changing the Time Zone
Example 3.4. Changing the Time Zone
timedatectlcommand with the
list-timezonescommand line option. For example, to list all available time zones in Europe, type:
timedatectl list-timezones | grep EuropeEurope/Amsterdam Europe/Andorra Europe/Athens Europe/Belgrade Europe/Berlin Europe/Bratislava …
Europe/Prague, type as
timedatectl set-timezone Europe/Prague
3.1.5. Synchronizing the System Clock with a Remote Server
timedatectlcommand also allows you to enable automatic synchronization of your system clock with a group of remote servers using the
NTPprotocol. Enabling NTP enables the
ntpdservice, depending on which of them is installed.
NTPservice can be enabled and disabled using a command as follows:
NTPserver, replace boolean with
yes(the default option). To disable this feature, replace boolean with
Example 3.5. Synchronizing the System Clock with a Remote Server
timedatectl set-ntp yes
NTPservice is not installed. See Section 17.3.1, “Installing chrony” for more information.