Linux Command Reference ยท System Information
Linux timedatectl command
Reference for timedatectl: show and set the system clock, time zone and NTP sync on systemd machines, and read the same facts from files in a sandbox.
timedatectl is the systemd tool for inspecting and changing the system clock, the time zone and time synchronization (NTP). One command shows the local time, UTC, the configured zone, whether the clock is synchronized and whether the hardware clock is kept in UTC.
It talks to the systemd-timedated service, so it only works on a machine running systemd. The examples that run here read the same information from plain files and date, which also works on systems without systemd.
timedatectl [status | show | set-time TIME | set-timezone ZONE | list-timezones | set-ntp BOOL]
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
timedatectl [OPTIONS] [COMMAND]
| Command | Description |
|---|---|
status |
Default. Local time, UTC, RTC time, zone, System clock synchronized, NTP service, RTC in local TZ. |
show |
The same facts as KEY=VALUE lines for scripts; add -p Timezone --value for one value. |
set-time "YYYY-MM-DD HH:MM:SS" |
Set the clock manually (turn NTP off first). Needs root. |
set-timezone ZONE |
Set the zone, for example Europe/Paris. Needs root. |
list-timezones |
One zone name per line (pipe to grep). |
set-ntp BOOL |
Enable or disable network time sync. |
set-local-rtc BOOL |
Keep the hardware clock in local time (only for dual-boot with Windows). |
Errors: Failed to connect to bus or System has not been booted with systemd in containers; Access denied for set commands without root.
Usage notes
- Zones, not offsets. Set a named zone (
America/Chicago), not a fixed offset, so daylight saving time is handled for you. - The zone is stored as a symlink:
/etc/localtimepoints into/usr/share/zoneinfo.set-timezonejust updates it (and/etc/timezoneon Debian-style systems). - Servers usually run in UTC. Logs from many machines then sort and compare without conversions. Keep display zones for users.
- NTP:
System clock synchronized: yesmeans a time service (systemd-timesyncd,chrony) has recently corrected the clock.set-timefails while NTP is active. - Per-process zone: set
TZ=...for one command, orexport TZin a script, instead of changing the machine setting. - Scripts: prefer
timedatectl show -p Timezone --valueover parsing thestatustable. - Containers share the host kernel clock; they only choose a zone (via
TZor a mounted/etc/localtime), they do not set the time.
Related
date,hostnamectl,locale- Lessons: printf and date, Cron and scheduling