Red Hat System Administration II
Adjust the time zone on a server and ensure that its system clock is synchronized with an NTP time source.
Outcomes
Change the time zone on a server.
Configure the server to synchronize its time with an NTP time source.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start logs-maintain
Instructions
Log in to the
serveramachine as thestudentuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$For this exercise, pretend that the
serveramachine is relocated to Haiti and that you need to update the time zone. Elevate the privileges of thestudentuser to run thetimedatectlcommand to update the time zone.Select the appropriate time zone for Haiti.
[student@servera ~]$
tzselectPlease identify a location so that time zone rules can be set correctly. Please select a continent, ocean, "coord", or "TZ". 1) Africa 2) Americas 3) Antarctica 4) Asia 5) Atlantic Ocean 6) Australia 7) Europe 8) Indian Ocean 9) Pacific Ocean 10) coord - I want to use geographical coordinates. 11) TZ - I want to specify the timezone using the Posix TZ format. #?2Please select a country whose clocks agree with yours. 1) Anguilla 19) Dominican Republic 37) Peru 2) Antigua & Barbuda 20) Ecuador 38) Puerto Rico 3) Argentina 21) El Salvador 39) St Barthelemy 4) Aruba 22) French Guiana 40) St Kitts & Nevis 5) Bahamas 23) Greenland 41) St Lucia 6) Barbados 24) Grenada 42) St Maarten (Dutch) 7) Belize 25) Guadeloupe 43) St Martin (French) 8) Bolivia 26) Guatemala 44) St Pierre & Miquelon 9) Brazil 27) Guyana 45) St Vincent 10) Canada 28) Haiti 46) Suriname 11) Caribbean NL 29) Honduras 47) Trinidad & Tobago 12) Cayman Islands 30) Jamaica 48) Turks & Caicos Is 13) Chile 31) Martinique 49) United States 14) Colombia 32) Mexico 50) Uruguay 15) Costa Rica 33) Montserrat 51) Venezuela 16) Cuba 34) Nicaragua 52) Virgin Islands (UK) 17) Curaçao 35) Panama 53) Virgin Islands (US) 18) Dominica 36) Paraguay #?28The following information has been given: Haiti Therefore TZ='America/Port-au-Prince' will be used. Selected time is now: Wed Mar 16 07:10:35 EDT 2022. Universal Time is now: Wed Mar 16 11:10:35 UTC 2022. Is the above information OK? 1) Yes 2) No #?1You can make this change permanent for yourself by appending the line TZ='America/Port-au-Prince'; export TZ to the file '.profile' in your home directory; then log out and log in again. Here is that TZ value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: America/Port-au-PrinceUpdate the time zone on the
serveramachine toAmerica/Port-au-Prince.[student@servera ~]$
sudo timedatectl set-timezone \America/Port-au-Prince[sudo] password for student:studentVerify that you correctly set the time zone to
America/Port-au-Prince.[student@servera ~]$
timedatectlLocal time: Wed 2022-03-16 07:13:25 EDT Universal time: Wed 2022-03-16 11:13:25 UTC RTC time: Wed 2022-03-16 11:13:24 Time zone: America/Port-au-Prince (EDT, -0400) System clock synchronized: no NTP service: inactive RTC in local TZ: no
Configure the
chronydservice on theserveramachine to synchronize the system time with theclassroom.example.comserver as the NTP time source.Edit the
/etc/chrony.confconfiguration file to specify theclassroom.example.comserver as the NTP time source. The following output shows the configuration line to add to the configuration file, which includes theiburstoption to speed up initial time synchronization:...output omitted... server classroom.example.com iburst ...output omitted...
Enable time synchronization on the
serveramachine. The command activates the NTP server with the settings from the/etc/chrony.confconfiguration file. That command might activate either thechronydor thentpdservice, depending on which service is currently installed on the system.[student@servera ~]$
sudo timedatectl set-ntp true
Verify that the
serveramachine configuration synchronizes with theclassroom.example.comtime source in the classroom environment.Verify that time synchronization is enabled on the
serveramachine.Note
If the output shows that the clock is not synchronized, then wait for a few seconds and rerun the
timedatectlcommand. It takes a few seconds to successfully synchronize the time settings with the time source.[student@servera ~]$
timedatectlLocal time: Wed 2022-03-16 07:24:13 EDT Universal time: Wed 2022-03-16 11:24:13 UTC RTC time: Wed 2022-03-16 11:24:13 Time zone: America/Port-au-Prince (EDT, -0400)System clock synchronized: yesNTP service: active RTC in local TZ: noVerify that the
serveramachine currently synchronizes its time settings with theclassroom.example.comtime source.The output shows an asterisk character (
*) in the source state (S) field for theclassroom.example.comNTP time source. The asterisk indicates that the local system time successfully synchronizes with the NTP time source.[student@servera ~]$
chronyc sources -v.-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current best, '+' = combined, '-' = not combined, | / 'x' = may be in error, '~' = too variable, '?' = unusable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 172.25.254.254 2 6 377 33 +84us[ +248us] +/- 21msReturn to the
workstationsystem as thestudentuser.[student@servera ~]$
exitlogout Connection to servera closed. [student@workstation ~]$