Managing the Date and Time in CentOS 7
In previous versions of RHEL and CentOS we have has a myriad of small commands used to manage the date and time elements, date, time, tzselect and hwclock. Now much of these features are amalgamated into the systemd ecosystem and timedatectl. Setting the time or date can be managed with systemd as it could prevously with the date command; however the format is much simplified. The one command sets both the system time and the hardware clock with the one hit. It is also possible to set the timezone with the command too and no need for tzselect. Beyond this, we can also see if time synchronisation is set. Easily being ably to see that the host gets time from the network.
With systemd now in on Ubuntu, Debian, Red Hat, Arch, SUSE there is hardly a distribution not using the systemd system and service manager and the ecosystem of tools. This unifies Linux in a way we have not seen before both simplifying the use of the commands by combining obviously functionality but also in giving a greater consistence in the CLI across distributions.
stack@devstack:~$ timedatectl Local time: Fri 2017-07-21 20:43:34 BST Universal time: Fri 2017-07-21 19:43:34 UTC RTC time: Fri 2017-07-21 19:43:32 Time zone: Europe/London (BST, +0100) Network time on: yes NTP synchronized: yes RTC in local TZ: no
We can look at the following to give a summary of some of the usage of the new command, noting that set-time can set the date and the time.
stack@devstack:~$ timedatectl #to display time and date information stack@devstack:~$ sudo timedatectl set-time 2014-07-19 #to set date stack@devstack:~$ sudo timedatectl set-time 15:12:00 #to set time stack@devstack:~$ sudo timedatectl set-timezone Europe/London #to set TZ
The video will help you through the process