Loading...

Lab 78: Managing Time with timedatectl

Inspect and manage system time configuration using timedatectl on a systemd-based Linux host. Validate current time and timezone, switch to UTC, toggle NTP synchronization, and perform a controlled manual time set for troubleshooting.

time systemd troubleshooting

Scenario

You need to confirm your host’s clock settings and adjust them to support a troubleshooting workflow. The system uses systemd and may be relying on NTP to maintain accurate time. Your job is to inspect current time state, switch timezone to UTC, temporarily disable NTP, set a manual time value, then restore NTP synchronization.

Operator context

Time changes can impact logs, certificates, scheduled jobs, and time-sensitive applications. Keep changes scoped and reversible, and re-enable synchronization when you are done.

Objective

  • Display current time, timezone, and NTP sync state with timedatectl.
  • Change timezone to UTC.
  • Disable NTP synchronization temporarily.
  • Manually set system time to a known value.
  • Re-enable NTP synchronization.

What You’ll Practice

  • Reading system clock state and RTC configuration via timedatectl.
  • Changing timezone with timedatectl set-timezone.
  • Toggling NTP with timedatectl set-ntp.
  • Performing a controlled manual time set with timedatectl set-time.

Walkthrough

Step 1 : Display current time and date settings.
Command
timedatectl

This provides a consolidated view of local time, UTC time, RTC settings, timezone, and NTP sync status. It is often the fastest way to confirm whether time issues are configuration related.

Local time: Tue 2025-07-29 09:34:15 EDT
Universal time: Tue 2025-07-29 13:34:15 UTC
RTC time: Tue 2025-07-29 13:34:14
Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Step 2 : Change timezone to UTC.
Command
sudo timedatectl set-timezone UTC

Switching to UTC is common on servers to standardize logs and reduce ambiguity across regions.

Time zone set to UTC.
Step 3 : Disable NTP synchronization.
Safety note

Disabling NTP removes automatic correction and can cause drift. Only disable it for controlled troubleshooting or when you must set time manually.

Command
sudo timedatectl set-ntp false

Systemd-managed NTP integration must be off to set time manually. If an NTP client is running, it may override your manual changes.

NTP synchronization disabled.
Step 4 : Manually set system time to 10:00:00.
Command
sudo timedatectl set-time 10:00:00

Manual time setting is sometimes required to recover from a misconfigured RTC, virtualization issues, or accidental time skew. Keep manual changes as short-lived as possible.

Time set to 10:00:00.
Step 5 : Re-enable NTP synchronization.
Command
sudo timedatectl set-ntp true

Restore synchronization so the host converges back to accurate time automatically. After re-enabling, re-run timedatectl to confirm the sync state returns to healthy.

NTP synchronization re-enabled.
Step 6 : Confirm final time state.
Command
timedatectl

Confirm timezone, NTP service state, and synchronization status are correct before closing the incident or ticket.

# Confirm:
# Time zone: UTC
# NTP service: active
# System clock synchronized: yes

Reference

  • timedatectl : Displays current time, timezone, RTC status, and NTP synchronization state.
  • timedatectl set-timezone <TZ> : Sets the system timezone (for example UTC).
  • timedatectl set-ntp true|false : Enables or disables NTP synchronization via systemd.
  • timedatectl set-time <TIME> : Sets system time manually (requires NTP disabled).