Time Configuration
TIME
Time View
Table 1 Time View
Command | Purpose |
|---|---|
show clock | Display the time zone and time of the system. |
show supported-timezones | Display the time zones the system supports. |
show clock
[Command] show clock
[Purpose] Display the time zone and time of the system.
[View] Privileged User View
[Use Cases]
sonic# show clock
2024-10-19 09:19:01 Tuesday UTC+0000show supported-timezones
[Command] show supported-timezones
[Purpose] Display the time zones the system supports.
[View] Privileged User View
[Use Cases]
sonic# show supported-timezonesTime Config
Table 2 Time Config
Command | Purpose |
|---|---|
clock datetime date time | Set the system time. |
clock timezone zone | Set the system time zone. |
clock datetime date time
[Command] clock datetime date time
[Purpose] Set the system time.
[Parameters]
Parameter | Description |
|---|---|
date | In YY-MM-DD format. |
time | In HH:MM:SS format. |
[View] Global Configuration View
[Use Cases]
sonic# configure
sonic(config)# clock datetime 2022-02-22 20:30:30clock timezone zone
[Command] clock timezone zone
[Purpose] Set the system time zone.
[Parameters]
Parameter | Description |
|---|---|
zone | The default time zone is UTC. |
[View] Global Configuration View
[Notes] Run command no clock timezone to restore the system time zone to default.
[Use Cases]
sonic# configure
sonic(config)# clock timezone Asia/ShangNTP
NTP(Network Time Protocol)is a protocol used to synchronize the time of individual machines on a network.
NTP View
Table 3 NTP View
Command | Purpose |
|---|---|
show ntp | Display NTP status. |
show ntp server | Display configuration of NTP Server. |
show ntp global | Display global configuration of NTP. |
show ntp authentication-keyid | Display NTP authentication Key. |
show ntp
[Command] show ntp
[Purpose] Display NTP status.
[View] Privileged User View
[Use Cases]
sonic# show ntp
remote refid st t when poll reach delay offset jitter
==============================================================================
*10.250.0.240 203.107.6.88 3 u 46 64 377 0.165 10.575 3.198show ntp server
[Command] show ntp server
[Purpose] Display configuration of NTP Server.
[View] Privileged User View
[Use Cases]
sonic# show ntp server
SERVER STATE TYPE KEY
------------ ------- ------ -----
10.250.0.242 enabled server -
10.250.0.243 enabled server -show ntp global
[Command] show ntp global
[Purpose] Display global configuration of NTP.
[View] Privileged User View
[Use Cases]
sonic# show ntp global
State: enabled
Authentication: disabled
VRF: defaultshow ntp authentication-keyid
[Command] show ntp global
[Purpose] Display NTP authentication key.
[View] Privileged User View
[Use Cases]
sonic# show ntp authentication-keyid
KEY ID TYPE TRUSTED
-------- ------ ---------
1 md5 yesNTP Config
Table 4 NTP Config
Command | Purpose |
|---|---|
ntp enable | Enable NTP automatic synchronization service. |
ntp server server-ip [authentication-keyid] | Specify a NTP server. |
ntp source_interface {mgmt|loopback|ethernet|link-aggregation|vlan} interface_name | Specify the source interface for NTP. |
ntp synchronize [unprivileged] server-ip | Synchronise manually from an NTP server. |
ntp synchronize jump | Enable NTP jump synchronization. |
ntp vrf {default|mgmt} | Specify the VRF where the NTP source interface is located. |
ntp authentication enable | Enable NTP authentication. |
ntp authentication-keyid key_id {md5|sha1|sha256|sha384|sha512} | Add NTP key. |
ntp enable
[Command] ntp enable
[Purpose] Enable NTP automatic synchronization service.
[View] Global Configuration View
[Notes] Run command no ntp enable to disable NTP.
[Use Cases]
sonic(config)# ntp enablentp server server-ip [authentication-keyid]
[Command] ntp server server-ip [authentication-keyid]
[Purpose] Specify a NTP server.
[Parameters]
Parameter | Description |
|---|---|
server-ip|NTP Server IP address or domain name. | - |
authentication-keyid| | - |
[View] Global Configuration View
[Notes] Run command no ntp server server-ip to delete NTP server configuration.
[Use Cases]
sonic(config)# ntp server 10.250.0.242ntp source_interface {mgmt|loopback|ethernet|link-aggregation|vlan} interface_name
[Command] ntp source_interface {mgmt|loopback|ethernet|link-aggregation|vlan} interface_name
[Purpose] Specify the source interface for NTP.
[Parameters]
Parameter | Description |
|---|---|
interface_name | Interface name (eg.0/1). When specify mgmt the interface name is 0. |
[View] Global Configuration View
[Notes] Run command no ntp source_interface to delete NTP source interface configuration.
[Use Cases]
sonic(config)# ntp source_interface mgmt 0
sonic(config)# ntp source_interface loopback 0ntp synchronize [unprivileged] server-ip
[Command] ntp synchronize [unprivileged] server-ip
[Purpose] Synchronise manually from an NTP server.
[Parameters]
Parameter | Description |
|---|---|
unprivileged | This parameter should be enabled when the NTP auto-sync service is already running so that manual synchronisation can be performed over an unprivileged port. |
server-ip | Specify NTP server IP address. |
[View] Global Configuration View
[Notes] When you run this command, the system will immediately synchronise to NTP server time. This command is valid for a single time and will not be saved to running-config.
[Use Cases]
sonic(config)# ntp synchronize unprivileged 10.250.0.243
18 Nov 20:10:52 ntpdate[385097]: adjust time server 10.250.0.243 offset -0.009762 secntp synchronize jump
[Command] ntp synchronize jump
[Purpose] Enable NTP jump synchronization.
[View] Global Configuration View
[Notes] With this command set, the system will make a time adjustment with a large offset every time the process restarts. By default a jump synchronization will be made only when the offset is over 600 seconds.
[Use Cases]
sonic(config)# ntp synchronize jumpntp vrf {default|mgmt}
[Command] ntp vrf {default|mgmt}
[Purpose] Specify the VRF where the NTP source interface is located.
[View] Global Configuration View
[Notes] When you have set the management port as NTP source interface as and enabled management VRF, please specify mgmt as NTP VRF. By default, the NTP VRF is default VRF.
[Use Cases]
sonic(config)# ntp vrf default
sonic(config)# ntp vrf mgmtntp authentication enable
[Command] ntp authentication enable
[Purpose] Enable NTP authentication
[View] Global Configuration View
[Notes] Run command no ntp authentication enable to disable NTP authentication
[Use Cases]
sonic(config)# ntp authentication enablentp authentication-keyid key_id {md5|sha1|sha256|sha384|sha512}
[Command] ntp authentication-keyid key_id {md5|sha1|sha256|sha384|sha512}
[Purpose] Add NTP key.
[View] Global Configuration View
[Notes] Run command no ntp authentication-keyid key_id to delete NTP key
[Use Cases]
sonic(config)# ntp authentication-keyid 1 md5
Please enter authentication key value:
sonic(config)#