Modern operating systems distinguish between the following two types of clocks:
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.
The system time is always kept in Coordinated Universal Time (UTC) and converted in applications to local time as needed. Local time is the actual time in your current time zone, taking into account daylight saving time (DST). The real-time clock can use either UTC or local time. UTC is recommended.
Red Hat Enterprise Linux 7 offers three command line tools that can be used to configure and display information about the system date and time: the
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.
2.1. USING THE
The timedatectl utility is distributed as part of 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.
2.1.1. Displaying the Current Date and Time
To display the current date and time along with detailed information about the configuration of the system and hardware clock, run the
timedatectlcommand with no additional command line options:
This displays the local and universal time, the currently used time zone, the status of the Network Time Protocol (
NTP) configuration, and additional information related to DST.
Example 2.1. Displaying the Current Date and Time
The following is an example output of the
timedatectlcommand on a system that does not use
NTPto synchronize the system clock with a remote server:
timedatectlLocal time: Mon 2013-09-16 19:30:24 CEST Universal time: Mon 2013-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 2013-03-31 01:59:59 CET Sun 2013-03-31 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2013-10-27 02:59:59 CEST Sun 2013-10-27 02:00:00 CET
Changes to the status of
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.services
2.1.2. Changing the Current Time
To change the current time, type the following at a shell prompt as
Replace HH with an hour, MM with a minute, and SS with a second, all typed in two-digit form.
This command updates both the system time and the hardware clock. The result it is similar to using both the
The command will fail if an
NTPservice is enabled.
Example 2.2. Changing the Current Time
To change the current time to 11:26 p.m., run the following command as
timedatectl set-time 23:26:00
By default, the system is configured to use UTC. To configure your system to maintain the clock in the local time, run the
timedatectlcommand with the
To configure your system to maintain the clock in the local time, replace boolean with
1). To configure the system to use UTC, replace boolean with
0). The default option is
To change the current date, type the following at a shell prompt as
Replace YYYY with a four-digit year, MM with a two-digit month, and DD with a two-digit day of the month.
Note that changing the date without specifying the current time results in setting the time to 00:00:00.
Example 2.3. Changing the Current Date
To change the current date to 2 June 2013 and keep the current time (11:26 p.m.), run the following command as
timedatectl set-time '2013-06-02 23:26:00'
2.1.4. Changing the Time Zone
To list all available time zones, type the following at a shell prompt:
To change the currently used time zone, type as
Replace time_zone with any of the values listed by the
Example 2.4. Changing the Time Zone
To identify which time zone is closest to your present location, use the
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 …
To change the time zone to
Europe/Prague, type as
timedatectl set-timezone Europe/Prague
As opposed to the manual adjustments described in the previous sections, the
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:
To enable your system to synchronize the system clock with a remote
NTPserver, replace boolean with
yes(the default option). To disable this feature, replace boolean with