===== Настройка службы синхронизации времени systemd-timesyncd в Debian GNU/Linux 12 (Bookworm) ===== {{:unix-linux:debian:pasted:20171124-194401.png }} В составе версии **systemd**, используемой в конфигурации по умолчанию в **Debian GNU/Linux 12** имеется отдельная служба, отвечающая за синхронизацию времени локальной системы по протоколу **NTP** с внешними NTP-серверами - **systemd-timesyncd**. Поэтому, если нужно настроить синхронизацию времени, например, с корпоративными NTP-серверами, нет необходимости устанавливать и настраивать специальные пакеты типа **ntp**, а достаточно лишь выполнить настройку **systemd-timesyncd**. Проверить текущее состояние службы можно командой
# systemctl status systemd-timesyncd
В свеже установленной ОС Debian Bookworm служба systemd-timesyncd будет запускаться автоматически. Отредактируем основной конфигурационный файл **systemd-timesyncd**:
# nano /etc/systemd/timesyncd.conf
# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation; either version 2.1 of the License, or (at your option) # any later version. # # Entries in this file show the compile time defaults. Local configuration # should be created by either modifying this file, or by creating "drop-ins" in # the timesyncd.conf.d/ subdirectory. The latter is generally recommended. # Defaults can be restored by simply deleting this file and all drop-ins. # # See timesyncd.conf(5) for details. [Time] NTP=ntp1.holding.com dc1.holding.com dc2.holding.com RootDistanceMaxSec=15 # #FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048 #ConnectionRetrySec=30 #SaveIntervalSec=60 Небольшое увеличение значения по умолчанию для ''RootDistanceMaxSec'' может быть полезно в больших и загруженных сетях, чтобы свести к минимуму ситуации, когда из-за низкого стандартного значения в 5s могут наблюдаться проблемы с прекращением синхронизации времени. После правки конфигурационного файла перезапускаем службу и проверяем её состояние:
# systemctl restart systemd-timesyncd
# systemctl status systemd-timesyncd
Состояние синхронизации времени можно проверить утилитой **timedatectl**:
# timedatectl status
Local time: Mon 2023-06-19 15:27:10 MSK Universal time: Mon 2023-06-19 12:27:10 UTC RTC time: Mon 2023-06-19 12:27:10 Time zone: Europe/Moscow (MSK, +0300) System clock synchronized: yes NTP service: active RTC in local TZ: no
Посмотреть лог службы **systemd-timesyncd** (как юнита **systemd**) можно следующей командой:
# journalctl -u systemd-timesyncd --since today

..systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization... ..systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization. ..systemd-timesyncd[..]: Contacted time server 10.1.0.4:123 (ntp1.holding.com). ..systemd-timesyncd[..]: Initial clock synchronization to Mon 2023-06-19 15:27:03.811980 MSK
Если же всё таки возникает необходимость использования других пакетов синхронизации времени, то можно остановить и отключить службу **systemd-timesyncd** парой простых команд:
# systemctl stop systemd-timesyncd
# systemctl disable systemd-timesyncd
---- Дополнительные источники информации: * [[https://manpages.debian.org/experimental/systemd-timesyncd/timesyncd.conf.5.en.html|Debian Manpages - systemd-timesyncd]] ---- Проверено на следующих конфигурациях: ^ Версия ОС ^ Версия systemd ^ |Debian GNU/Linux Bullseye 12.0 | 252.6-1 amd64 | ---- {{:user:blogroot.png?50&nolink |}} Автор первичной редакции:\\ [[user:blogroot|Алексей Максимов]] \\ Время публикации: 19.06.2023 16:37 {{tag>Linux Debian "Debian 12" "Debian Bookworm" NTP systemd systemd-timesyncd timesyncd timedatectl}} ~~DISCUSSION~~