Configure time synchronization with an external NTP server
In ready-made images cloud servers all the necessary settings for NTP executed. Customization is required if you Prepare your ISO image to work with the cloud platform.
Linux
Windows
Check the installed utility
-
Connect to the server via SSH or through console in the control panel.
-
Check which utility is being used on the server:
systemctl status ntp
systemctl status chronyd
systemctl status systemd-timesyncdWe recommend the use of
Chrony
But you can customize the utility that is already installed on the server. -
If you want to go to
Chrony
disable and uninstall the utilitiessystemd-timesyncd
andntpd
and setChrony
:systemctl disable <name>
sudo apt remove <name>
sudo apt-get install chronydSpecify
<name>
— the name of the utility to be deleted (ntp
orsystemd-timesyncd
).
Customize the utility
Chrony
ntpd
systemd-timesyncd
-
Run
Chrony
:systemctl start chronyd
-
Open the configuration file
Chrony
word processingvi
:vi /etc/chrony/chrony.conf
-
Add or replace the NTP servers in the file. We recommend replacing the servers in the file with Selectel NTP servers But you can specify any available NTP servers.
server <domain> iburst
Specify
<domain>
— domain name or address of the pool or server.If you need to specify multiple servers, specify each on a separate line, for example:
server 0.spb.ntp.selectel.ru iburst
server 1.spb.ntp.selectel.ru iburst -
Exit the text editor
vi
with the changes intact::wq
-
Restart the utility
Chrony
:sudo systemctl restart chronyd
-
Check the list of NTP servers in use:
chronyc -N sources
-
Open the configuration file
ntpd
word processingvi
:vi /etc/ntp.conf
-
Add or replace the NTP servers in the file. We recommend replacing the servers in the file with Selectel NTP servers But you can specify any available NTP servers.
server <domain> iburst
Specify
<domain>
— domain name or address of the pool or server.If you need to specify multiple servers, specify each on a separate line, for example:
server 0.spb.ntp.selectel.ru iburst
server 1.spb.ntp.selectel.ru iburst -
Exit the text editor
vi
with the changes intact::wq
-
Restart the utility
ntpd
:sudo systemctl restart ntpd
-
Check the list of NTP servers in use:
ntpq -p
-
Open the configuration file
ntpd
word processingvi
:vi /etc/systemd/timesyncd.conf
-
In the parameter
NTP
add or replace NTP servers. We recommend replacing the servers with Selectel NTP servers But you can specify any available NTP servers.NTP=<domain>
Specify
<domain>
— domain name or NTP server address.If you need to specify multiple NTP servers, enter them separated by a space, for example:
NTP=0.spb.ntp.selectel.ru 1.spb.ntp.selectel.ru
-
Exit the text editor
vi
with the changes intact::wq
-
Restart the utility
systemd-timesyncd
:sudo systemctl restart systemd-timesyncd.service
-
Check that the utility is running and the time is synchronized:
timedatectl status
In the reply, in the field
NTP service
should appearactive
in the fieldSystem clock synchronized
—yes
.
-
Open cmd.
-
Stop the Windows time service:
net stop w32time
-
Specify the NTP servers. We recommend replacing the servers with Selectel NTP servers But you can specify any available NTP servers.
w32tm /config /syncfromflags:manual /manualpeerlist:"<domain>" /update
Specify
<domain>
— domain name or NTP server address.If you need to specify multiple NTP servers, enter them separated by a space, for example:
w32tm /config /syncfromflags:manual /manualpeerlist:"0.spb.ntp.selectel.ru 1.spb.ntp.selectel.ru" /update
-
Start the Windows Time Service:
net start w32time
-
Check the list of NTP servers in use:
w32tm /query /peers