Home Linux How to set time, date and timezone using timedatectl in CentOS /...

How to set time, date and timezone using timedatectl in CentOS / RHEL 7

0

Redhat Linux 7 have one utility to display and configure date and time information, which is timedatectl. This utility tool is a part of systemd system and service manager.

Using this timedateclt command, you can:
1. View the time and date
2. Change the current date and time
3. Set the time zone
4. Configure NTP

1. Display the time and date
If you want to show the time and date with local time, universal time, RTC time, time zone, NTP configuration and Daylight Savings Time (DST), use the command:

# timedatectl
Local time: Sat 2019-05-11 20:21:04 BDT
Universal time: Sat 2019-05-11 14:21:04 UTC
RTC time: Sat 2018-02-03 01:55:05
Timezone: Asia/Dhaka (BDT, +0600)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

2. Change the current date and time
If you want to change the current date and time, use the set-time argument.

i) To change the date, use the following command:
# timedatectl set-time [YYYY-MM-DD]

ii) To set the current time, use the following command. Here, use time as 24-hour clock format.
# timedatectl set-time [HH:MM:SS]

iii) To configure your system to maintain the clock in the local time, use the following command:
# timedatectl set-local-rtc yes

iv). Use the following command to configure your system to use UTC:
# timedatectl set-local-rtc no

3. Change the Time Zone
Use the following command to view the list of all available time zones:
# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
…..

If you want to change the time zone, use set-timezone argument.
# timedatectl set-timezone Asia/Dhaka
Ex: This command change the time zone to Asia/Dhaka:

4. Configuring NTP Synchronization
If you need to enable or disable automatic synchronization of your system clock with remote server over the NTP protocol, user the set-ntp argument.
Use the following command to enable this feature:
# timedatectl set-ntp yes

To disable this automatic synchronization over NTP, use the following command:
# timedatectl set-ntp no

NO COMMENTS