In this article we look at how to configure System Timezone and date on a RHEL 6 / CentOS 6 system. A time zone is a designated area of the globe that observes a uniform standard time for legal, commercial and social purposes. The way you’ll change time zone on RHEL 7 is different from how it is done on RHEL 6. This is because RHEL 7 comes with Systemd where administration of the system got many improvements.
On RHEL 6 / CentOS 6 system, Timezones are applied locally by the system through a zone information file located in /usr/share/zoneinfo. The /etc/localtime is a symlink to zoneinfo file.
Configure Timezone on RHEL 6 / CentOS 6
To set correct timezone on a RHEL 6 / CentOS 6 system, edit /etc/sysconfig/clock and change the ZONE= declaration in to ensure the time zone is read properly.
$ sudo vi /etc/sysconfig/clock ZONE="Africa/Nairobi"
Once the file has been modified, run tzdata-update command which will reconfigure your system time zone:
This will update file /etc/localtime and notify the operating system that there was a time zone change. No reboot is required when setting timezone.
Configure Date on RHEL 6 / CentOS 6
Let’s install and configure NTP server using Chrony. Install the package by running the command below.
sudo yum -y install chrony
Use NTP servers closest to you.
$ sudo vi /etc/chrony.conf
Start chronyd service.
sudo service chronyd start
Enable service to start at system boot.
sudo chkconfig chronyd on
Verify NTP server is working correctly.
$ sudo chronyc sources # Also check date and time $ date
See screenshot from my configurations below.
If using this system as NTP server and would like to enable iptables firewall use the commands below.
sudo iptables -I INPUT 5 -p udp -m state --state NEW -m udp --dport 123 -j ACCEPT
To this end timezone and NTP has been configured on your RHEL 6 / CentOS 6 system. For more informative tutorials check below articles.