Exercise: Time zone and time sources
Read the state of servera's clock, move it to another time zone, inspect where its time comes from, and add a time source to the chrony configuration.
Time zone and time sources
- Read timedatectl, chronyc sources and chronyc tracking.
- Change the time zone.
- Add an NTP server and verify it.
Start the exercise
On workstation, start the exercise. It puts servera in the UTC time zone and removes an extra time source from an earlier run.
[student@workstation ~]$ lab start sa-timeLater tasks assume that you are logged in to the server they name: ssh student@servera from workstation, then sudo -i for a root shell.
Check the clock
On servera as root, show the time status, the time sources, and the clock offset.
[student@workstation ~]$ ssh student@servera
[student@servera ~]$ sudo -i
[root@servera ~]# timedatectl | grep -E 'Time zone|synchronized|NTP'
Time zone: UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
[root@servera ~]# chronyc sources | head -4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- ntp2.ntp.net.nz 1 6 37 51 +1130us[+1130us] +/- 3864us
^* 132.181.2.72 1 6 37 51 -13us[-4847us] +/- 9289us
[root@servera ~]# chronyc tracking | grep -E 'Stratum|System time'
Stratum : 2
System time : 0.000004469 seconds fast of NTP timeYour sources will be different servers. Which one has the *?
Change the time zone
Find the zone name for Colombo, set it, and compare date with date -u. Then set it back to UTC.
[root@servera ~]# timedatectl list-timezones | grep -i colombo
Asia/Colombo
[root@servera ~]# timedatectl set-timezone Asia/Colombo
[root@servera ~]# date; date -u
Sat Oct 3 22:29:50 +0530 2026
Sat Oct 3 16:59:50 UTC 2026
[root@servera ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 34 Oct 3 22:31 /etc/localtime -> ../usr/share/zoneinfo/Asia/Colombo
[root@servera ~]# timedatectl set-timezone UTCThe time zone is just a link in /etc/localtime. Both lines show the same moment.
Try to set the time by hand
Try timedatectl set-time '2026-01-01 12:00:00'. What stops you? (Do not turn NTP off.)
[root@servera ~]# timedatectl set-time '2026-01-01 12:00:00'
Failed to set time: Automatic time synchronization is enabledWith NTP on, the system will not let you set the time. This protects the machine from well-meaning mistakes.
Add a time source
Add the line server 0.pool.ntp.org iburst to /etc/chrony.conf, restart chronyd, wait a few seconds and look at the sources. Is the new server there?
[root@servera ~]# cp /etc/chrony.conf /root/chrony.conf.bak
[root@servera ~]# echo 'server 0.pool.ntp.org iburst' >> /etc/chrony.conf
[root@servera ~]# systemctl restart chronyd
[root@servera ~]# sleep 10; chronyc sources | head -8
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 132.181.2.72 1 6 17 3 -523us[ +365us] +/- 9620us
^- 33.static.cloudbase.co.nz 2 6 17 2 -4606us[-3671us] +/- 67ms
^+ zappa.convolute.net.nz 1 6 17 2 -171us[ +812us] +/- 33ms
^+ time.cloudflare.com 3 6 17 3 -115us[ +711us] +/- 17msThe pool name 0.pool.ntp.org is not listed as such: DNS turns it into several real servers, and chronyc sources shows those. You should see more servers than before. Output varies with the network.
Restore the configuration
[root@servera ~]# cp /root/chrony.conf.bak /etc/chrony.conf
[root@servera ~]# systemctl restart chronyd
[root@servera ~]# timedatectl | grep -E 'synchronized|NTP'
System clock synchronized: no
NTP service: active
[root@servera ~]# rm /root/chrony.conf.bak
[root@servera ~]# exit
[student@servera ~]$ exitRight after a restart, synchronized may say no for a few moments, until chronyd has chosen a source again. It says yes again within a minute or two.
Grade and finish
Check your work with lab grade sa-time, then put the exercise away with lab finish sa-time.