Time, hostname, locale.
chrony, timedatectl, hostnamectl, localectl.
Audit logs are drifting four minutes off real time, which breaks correlation for compliance. Sync the clock with chrony and confirm timezone, hostname, and locale with the systemd control tools.
auditor1 opened this one because server1’s clock is running four minutes fast, and four minutes is plenty to make the audit logs useless: you cannot line an event on this box up against the same event on another box when the timestamps disagree. So the clock has to genuinely sync, via chrony against time.cloudflare.com and pool.ntp.org, the timezone has to read America/New_York, and the hostname and locale get confirmed while you are already in there.
None of this is hard once you know which tool owns which setting, and that is the real content: chronyc for the sync, timedatectl for time and timezone, hostnamectl for the name, localectl for the locale. The one part that takes practice is reading chrony’s source table to confirm the clock actually locked onto something instead of just reaching for it.
The ticket
sudo dnf install -y chrony systemctl is-active chronyd timedatectl
Concept review. The control tools.
man chronyc man timedatectl man hostnamectl man localectl
chronyc live chrony queries, sources and tracking timedatectl time, date, timezone, and the NTP toggle hostnamectl the static and transient hostname localectl the system locale and keymap
Configure chrony
Back up the config, strip the default pool and server lines, and add the two sources the ticket asked for. iburst makes the first sync happen in seconds instead of minutes.
sudo cp /etc/chrony.conf /etc/chrony.conf.bak sudo sed -i '/^pool /d; /^server /d' /etc/chrony.conf sudo bash -c 'cat >> /etc/chrony.conf << EOF server time.cloudflare.com iburst pool pool.ntp.org iburst EOF' grep -E '^pool|^server' /etc/chrony.conf
Verify the sync
Restart chrony, give it a few seconds, then read the sources and the tracking. In chronyc sources, the marker at the start of a line tells you the state: ^* is the selected source, ^+ is combined in, ^- is excluded, and ^? is unreachable.
sudo systemctl enable --now chronyd sudo systemctl restart chronyd sleep 5 chronyc sources # MS Name/IP address Stratum Poll Reach LastRx Last sample # ^* time.cloudflare.com 3 6 377 17 -42us[ -61us] +/- 12ms # the ^* is what you are looking for: this source is selected and in use chronyc tracking # Stratum : 4 # System time : 0.000038 seconds fast of NTP time <- no longer 4 minutes
timedatectl for time and timezone
One command shows the whole time picture, including whether the clock is synchronized and NTP is active. Setting the timezone through timedatectl validates the name and fixes the /etc/localtime link for you.
timedatectl # local time, timezone, synced?, NTP active? timedatectl list-timezones | grep -i new_york sudo timedatectl set-timezone America/New_York # timedatectl also toggles NTP, since it manages chronyd sudo timedatectl set-ntp true timedatectl | grep -i ntp
Hostname and locale
Confirm the hostname, then set the system locale. The locale change applies at the next login.
hostnamectl sudo hostnamectl set-hostname server1 localectl localectl list-locales | grep en_US sudo localectl set-locale LANG=en_US.UTF-8
Exam questions
Write the command first.
Q1. Display the current time, timezone, and NTP sync status in one command.
Q2. Set the system timezone to Europe/London and verify.
Q3. Configure chrony to use time.cloudflare.com as a source, restart, and confirm it is being used.
Answers.
# A1 timedatectl # A2 sudo timedatectl set-timezone Europe/London timedatectl # A3 echo 'server time.cloudflare.com iburst' | sudo tee -a /etc/chrony.conf sudo systemctl restart chronyd; sleep 5 chronyc sources -v # expect ^* on time.cloudflare.com
Final checklist: confirm everything works
If every check passes, the ticket is done.
# 1. chrony configured with the two sources and syncing chronyc tracking; chronyc sources -v # 2. timezone America/New_York, NTP active timedatectl # 3. hostname server1, locale en_US.UTF-8 hostnamectl; localectl # 4. all three exam commands written from scratch # 5. tracker entry checked off
Reply to auditor1: time drift fixed. chrony is synced to Cloudflare and the ntp.org pool, timedatectl confirms America/New_York with NTP active and the clock synchronized. Hostname and locale verified.