timedatectl
(1)Control the system time and date
Options
12--adjust-system-clockIf set-local-rtc is invoked and this option is passed, the system clock is synchronized from the RTC again, taking the new setting into account. Otherwise, the RTC is synchronized from the system clock. Added in version 195.
--monitorIf timesync-status is invoked and this option is passed, then timedatectl monitors the status of systemd-timesyncd.service(8) and updates the outputs. Use Ctrl+C to terminate the monitoring. Added in version 239.
-a--allWhen showing properties of systemd-timesyncd.service(8), show all properties regardless of whether they are set or not. Added in version 239.
-p--propertyWhen showing properties of systemd-timesyncd.service(8), limit display to certain properties as specified as argument. If not specified, all set properties are shown. The argument should be a property name, such as "ServerName". If specified more than once, all properties with the specified names are shown. Added in version 239.
--valueWhen printing properties with show-timesync, only print the value, and skip the property name and "=". Added in version 239.
-PEquivalent to --value --property=, i.e. shows the value of the property without the property name or "=". Note that using -P once will also affect all properties listed with -p/--property=. Added in version 256.
-H--hostExecute the operation remotely. Specify a hostname, or a username and hostname separated by "@", to connect to. The hostname may optionally be suffixed by a port ssh is listening on, separated by ":", and then a container name, separated by "/", which connects directly to a specific container on the specified host. This will use SSH to talk to the remote machine manager instance. Container names may be enumerated with machinectl -H HOST. Put IPv6 addresses in brackets.
-M--machineExecute operation on a local container. Specify a container name to connect to, optionally prefixed by a user name to connect as and a separating "@" character. If the special string ".host" is used in place of the container name, a connection to the local system is made (which is useful to connect to a specific user's user bus: "--user --machine=lennart@.host"). If the "@" syntax is not used, the connection is made as root user. If the "@" syntax is used either the left hand side or the right hand side may be omitted (but not both) in which case the local user name and ".host" are implied.
--no-ask-passwordDo not query the user for authentication for privileged operations.
-h--helpPrint a short help text and exit.
--versionPrint a short version string and exit.
--no-pagerDo not pipe output into a pager.
DESCRIPTION
timedatectl may be used to query and change the system clock and its settings, and enable or disable time synchronization services.
Use systemd-firstboot(1) to initialize the system time zone for mounted (but not booted) system images.
timedatectl may be used to show the current status of time synchronization services, for example systemd-timesyncd.service(8).
COMMANDS
The following commands are understood:
status
Added in version 195.
show
By default, empty properties are suppressed. Use --all to show those too. To select specific properties to show, use --property=.
Added in version 239.
set-time [TIME]
Added in version 195.
set-timezone [TIMEZONE]
Added in version 195.
list-timezones
Added in version 195.
set-local-rtc [BOOL]
Added in version 195.
set-ntp [BOOL]
Added in version 195.
systemd-timesyncd Commands
The following commands are specific to systemd-timesyncd.service(8).
timesync-status
Added in version 239.
show-timesync
By default, empty properties are suppressed. Use --all to show those too. To select specific properties to show, use --property=.
Added in version 239.
ntp-servers INTERFACE SERVER...
Added in version 243.
revert INTERFACE
Added in version 243.
EXIT STATUS
ENVIRONMENT
$SYSTEMD_LOG_LEVEL
$SYSTEMD_LOG_COLOR
This setting is only useful when messages are written directly to the terminal, because journalctl(1) and other tools that display logs will color messages based on the log level on their own.
$SYSTEMD_LOG_TIME
This setting is only useful when messages are written directly to the terminal or a file, because journalctl(1) and other tools that display logs will attach timestamps based on the entry metadata on their own.
$SYSTEMD_LOG_LOCATION
Note that the log location is often attached as metadata to journal entries anyway. Including it directly in the message text can nevertheless be convenient when debugging programs.
$SYSTEMD_LOG_TID
Note that the this information is attached as metadata to journal entries anyway. Including it directly in the message text can nevertheless be convenient when debugging programs.
$SYSTEMD_LOG_TARGET
$SYSTEMD_LOG_RATELIMIT_KMSG
$SYSTEMD_PAGER, $PAGER
Note: if $SYSTEMD_PAGERSECURE is not set, $SYSTEMD_PAGER and $PAGER can only be used to disable the pager (with "cat" or ""), and are otherwise ignored.
$SYSTEMD_LESS
Users might want to change two options in particular:
K
If the value of $SYSTEMD_LESS does not include "K", and the pager that is invoked is less, Ctrl+C will be ignored by the executable, and needs to be handled by the pager.
X
Note that setting the regular $LESS environment variable has no effect for less invocations by systemd tools.
See less(1) for more discussion.
$SYSTEMD_LESSCHARSET
Note that setting the regular $LESSCHARSET environment variable has no effect for less invocations by systemd tools.
$SYSTEMD_PAGERSECURE
This option takes a boolean argument. When set to true, the "secure mode" of the pager is enabled. In "secure mode", LESSSECURE=1 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses. Currently only less(1) is known to understand this variable and implement "secure mode".
When set to false, no limitation is placed on the pager. Setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited environment may allow the user to invoke arbitrary commands.
When $SYSTEMD_PAGERSECURE is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it. "Secure mode" is enabled if the effective UID is not the same as the owner of the login session, see geteuid(2) and sd_pid_get_owner_uid(3), or when running under sudo(8) or similar tools ($SUDO_UID is set [1]). In those cases, SYSTEMD_PAGERSECURE=1 will be set and pagers which are not known to implement "secure mode" will not be used at all. Note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as convenience. It is recommended to explicitly set $SYSTEMD_PAGERSECURE or disable the pager.
Note that if the $SYSTEMD_PAGER or $PAGER variables are to be honoured, other than to disable the pager, $SYSTEMD_PAGERSECURE must be set too.
$SYSTEMD_COLORS
$SYSTEMD_URLIFY
EXAMPLES
Show current settings:
$ timedatectl
Local time: Thu 2017-09-21 16:08:56 CEST
Universal time: Thu 2017-09-21 14:08:56 UTC
RTC time: Thu 2017-09-21 14:08:56
Time zone: Europe/Warsaw (CEST, +0200) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Enable network time synchronization:
$ timedatectl set-ntp true ==== AUTHENTICATING FOR org.freedesktop.timedate1.set-ntp === Authentication is required to control whether network time synchronization shall be enabled. Authenticating as: user Password: ******** ==== AUTHENTICATION COMPLETE ===
$ systemctl status systemd-timesyncd.service ● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled)
Active: active (running) since Mo 2015-03-30 14:20:38 CEST; 5s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 595 (systemd-timesyn)
Status: "Using Time Server 216.239.38.15:123 (time4.google.com)."
CGroup: /system.slice/systemd-timesyncd.service
└─595 /usr/lib/systemd/systemd-timesyncd ...
Show current status of systemd-timesyncd.service(8):
$ timedatectl timesync-status
Server: 216.239.38.15 (time4.google.com) Poll interval: 1min 4s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 1
Reference: GPS
Precision: 1us (-20) Root distance: 335us (max: 5s)
Offset: +316us
Delay: 349us
Jitter: 0
Packet count: 1
Frequency: -8.802ppm