Difference between revisions of "Redhat7:date"

From Define Wiki
Jump to navigation Jump to search
Line 21: Line 21:
 
# set time zone
 
# set time zone
 
timedatectl list-timezones
 
timedatectl list-timezones
timedaectl set-timezone time_zone
+
timedatectl set-timezone time_zone
 
# Synchronise using ntp
 
# Synchronise using ntp
 
timedatectl set-ntp boolean
 
timedatectl set-ntp boolean
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== date command ==
 
== date command ==

Revision as of 17:19, 20 February 2015

Types of Clocks

There are two separate clocks on a system, and most modern OS's distinguish between them.

  • Real-Time Clock - Also know as the hardware clock, this clock runs independently of the OS, and continues even when the system is shotdown
  • System Clock - Maintained by the kernel of the OS. This can be set to use Univerisal Time (UTC) or the local time. It is recommended to us UTC.


timedatectl command

As with the other ctl command the timedateclt works in a similar way.

#Display current time and date
timedatectl
#set date
timedatectl set-time YYYY-MM-DD
#set time
timedatectl set-time HH:MM:SS
# set time zone
timedatectl list-timezones
timedatectl set-timezone time_zone
# Synchronise using ntp
timedatectl set-ntp boolean

date command

#Display current time and date
date --utc
#set date
date +%F -s YYYY-MM-DD
#set time
date +%T -s HH:MM:SS