===== Настройка службы синхронизации времени systemd-timesyncd в Debian GNU/Linux 9 (Stretch) ===== {{:unix-linux:debian:pasted:20171124-194401.png }} В составе обновлённой версии **systemd**, используемой в конфигурации по умолчанию в **Debian GNU/Linux 9** имеется отдельная служба, отвечающая за синхронизацию времени локальной системы по протоколу **NTP** с врешними NTP-серверами - **systemd-timesyncd**. Поэтому, если нужно настроить синхронизацию времени, например с корпоративными NTP-серверами, нет необходимости устанавливать и настраивать специальные пакеты типа **ntp** (как это было в прошлых версиях Debian), а достаточно лишь выполнить настройку **systemd-timesyncd**. Проверить текущее состояние службы можно командой
# systemctl status systemd-timesyncd
Служба будет запускаться в системе автоматически в том случае, если не были обнаружены исполняемые файлы других пакетов, реализующих функции синхронизации времени. Эти исполняемые файлы можно увидеть в конфигурационном файл ''/lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf'' [Unit] # don't run timesyncd if we have another NTP daemon installed ConditionFileIsExecutable=!/usr/sbin/ntpd ConditionFileIsExecutable=!/usr/sbin/openntpd ConditionFileIsExecutable=!/usr/sbin/chronyd ConditionFileIsExecutable=!/usr/sbin/VBoxService Отредактируем основной конфигурационный файл **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. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See timesyncd.conf(5) for details. [Time] NTP=kom-dc01.holding.com kom-dc02.holding.com #FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org После правки конфигурационной файла перезапускаем службу и проверяем её состояние:
# systemctl restart systemd-timesyncd # systemctl status systemd-timesyncd
Состояние синхронизации времени можно проверить утилитой **timedatectl**:
# timedatectl status
Local time: Sat 2017-12-02 13:26:27 MSK Universal time: Sat 2017-12-02 10:26:27 UTC RTC time: Sat 2017-12-02 10:26:27 Time zone: Europe/Moscow (MSK, +0300) Network time on: yes NTP synchronized: yes RTC in local TZ: no
Посмотреть лог службы **systemd-timesyncd** (как юнита **systemd**) можно следующей командой:
# journalctl -u systemd-timesyncd --since today
-- Logs begin at Sat 2017-12-02 13:23:50 MSK, end at Sat 2017-12-02 13:27:22 MSK. -- Dec 02 13:23:51 SRV01 systemd[1]: Starting Network Time Synchronization... Dec 02 13:23:52 SRV01 systemd[1]: Started Network Time Synchronization. Dec 02 13:24:26 SRV01 systemd-timesyncd[256]: Synchronized to time server 10.1.1.2:123...
Если же всё таки возникает необходимость использования других пакетов синхронизации времени, исполняемые файлы которых отличны от тех, что перечислены в ''disable-with-time-daemon.conf'', то можно самостоятельно остановить и отключить службу **systemd-timesyncd** парой простых команд:
# systemctl stop systemd-timesyncd # systemctl disable systemd-timesyncd
---- Дополнительные источники информации: * [[https://www.freedesktop.org/software/systemd/man/timesyncd.conf.html|man timesyncd.conf]] * [[https://wiki.archlinux.org/index.php/Systemd-timesyncd_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)|wiki archlinux - systemd-timesyncd]] ---- Проверено на следующих конфигурациях: ^ Версия ОС ^ |Debian GNU/Linux Stretch 9.2.1 | ---- {{:user:blogroot.png?50&nolink |}} Автор первичной редакции:\\ [[user:blogroot|Алексей Максимов]] \\ Время публикации: 02.12.2017 14:03 {{tag>Linux Debian "Debian 9" "Debian Stretch" NTP systemd systemd-timesyncd timesyncd timedatectl}} ~~DISCUSSION~~