May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Manage Time service on RH and CentOS 7

When Linux system first boots the hardware clock is read first. The time on the hardware clock read from local hardware clock in UTC – Universal Time. Local time is the actual time in the current time zone. System time, unlike Hardware clock maintained by operating system. System clock is completely independent of the hardware clock.
How to manage time
Command Description
date Manage local time
hwclock Manage hardware time
timedatectl Manage time on CentOS 7 or RH 7
Examples of using date
root@on ~]# date
Wed Jun 7 13:34:40 EDT 2017
[root@on ~]# date +%d-%m-%y
07-06-17
[root@on ~]# date -s 13:40:00
Wed Jun 7 13:40:00 EDT 2017
[root@on ~]# date
Wed Jun 7 13:40:05 EDT 2017
[root@on ~]#
Examples of using hwclock
[root@on ~]# hwclock -c
hw-time system-time freq-offset-ppm tick
1496857021 1496857310.458797
1496857031 1496857320.459274 48 0
1496857041 1496857330.459571 39 0
[root@on ~]# hwclock –systohc
[root@on ~]# hwclock -c
hw-time system-time freq-offset-ppm tick
1496857353 1496857353.012685
1496857363 1496857363.013179 49 0
1496857373 1496857373.013471 39 0
hwclock command meaning
hwclock -c shows the difference between hardware time and system time.
The output of this command is refreshed every 10 seconds. Listing 24.1 shows
the output of this command.
hwclock –systohc synchronizes current system time to the hardware clock.
hwclock –hctosys synchronizes current hardware time to the system clock.
Examples using timedatectl command
[root@on ~]# timedatectl
Local time: Wed 2017-06-07 13:48:01 EDT
Universal time: Wed 2017-06-07 17:48:01 UTC
RTC time: Wed 2017-06-07 17:48:01
Time zone: America/New_York (EDT, -0400)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2017-03-12 01:59:59 EST
Sun 2017-03-12 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2017-11-05 01:59:59 EDT
Sun 2017-11-05 01:00:00 EST
[root@on ~]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
….
[root@on ~]# timedatectl set-timezone America/Toronto
[root@on ~]# timedatectl
Local time: Wed 2017-06-07 13:50:09 EDT
Universal time: Wed 2017-06-07 17:50:09 UTC
RTC time: Wed 2017-06-07 17:50:09
Time zone: America/Toronto (EDT, -0400)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2017-03-12 01:59:59 EST
Sun 2017-03-12 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2017-11-05 01:59:59 EDT
Sun 2017-11-05 01:00:00 EST
[root@on ~]#

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>