RHEL 7 offers another utility to configure and display date and time information, timedatectl. This utility is part of the systemd system and service manager. With the timedatectl command you can :

  • Change the current date and time
  • Set the time zone
  • Configure NTP

 

If you run timedatectl without any options, you would get an output similar to below :

# timedatectl 
      Local time: Sun 2017-09-24 13:16:39 IST
  Universal time: Sun 2017-09-24 07:46:39 UTC
        RTC time: Sun 2017-09-24 07:46:39
       Time zone: Asia/Kolkata (IST, +0530)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

 

The above output shows – local time, universal time, RTC time, time zone, NTP configuration and Daylight Savings Time (DST)

 

Change the current date and time

 

Use the set-time argument to change the current date and the current time.

 

1. To change the date, use the following syntax:

# timedatectl set-time [YYYY-MM-DD]

 

2. To change the current time, use the following syntax. Enter the hour by using a 24-hour clock.

# timedatectl set-time [HH:MM:SS]

 

3. To configure your system to maintain the clock in the local time, use the following command:

# timedatectl set-local-rtc yes

 

4. To configure your system to use UTC, use the following command:

# timedatectl set-local-rtc no

 

Change Time Zone

 

Use the following command to list all available time zones:

# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
.....

 

Use the set-timezone argument to change the time zone. The following example changes the time zone to Asia/Kolkata:

# timedatectl set-timezone Asia/Kolkata

 

Configuring NTP

 

Use the set-ntp argument to enable or disable automatic synchronization of your system clock with a remote server over the Network Time Protocol (NTP). Use the following command to enable this feature:

# timedatectl set-ntp yes

 

Use the following command to disable this automatic synchronization over NTP:

# timedatectl set-ntp no

 

Was this answer helpful? 0 Users Found This Useful (1 Votes)