Warning: the hardware clock does not need to be updated on XEN guests. NTP can be used to keep the system clock in sync, though.

ubuntu

reqs

apt install nmap netcat ntpdate ntp ntpstat

timezone

#timedatectl set-timezone Europe/Paris
timedatectl set-timezone Europe/Moscow
dpkg-reconfigure tzdata
cat /etc/timezone
ls -lhF /etc/localtime*

#echo 'Europe/Moscow' > /etc/timezone
#echo 'Europe/Paris' > /etc/timezone

one shot

#ntpsrv=ntp.obspm.fr
ntpsrv=0.ru.pool.ntp.org
ping -c1 $ntpsrv
nmap -sU -p123 $ntpsrv

#ubuntu
systemctl stop ntp
ntpdate -u $ntpsrv
hwclock --systohc

continuous time sync

mv -i /etc/ntp.conf /etc/ntp.conf.dist
sed '/^$/d;/^#/d; s/ubuntu.pool/ru.pool/' /etc/ntp.conf.dist > /etc/ntp.conf
vi /etc/ntp.conf

#server ntp.obspm.fr iburst

cat /etc/systemd/timesyncd.conf

systemctl start ntp
systemctl enable ntp

note. dhclient settings my override those.

slackware

reqs

ls -l /var/log/packages/ntp-*
#slackpkg install ntp

timezone

ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime
#ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
ls -lhF /etc/localtime*

one shot

ntpsrv=0.ru.pool.ntp.org
ping -c1 $ntpsrv
nmap -sU -p123 $ntpsrv

#slackware
/etc/rc.d/rc.ntpd stop
ntpdate -u $ntpsrv
hwclock --systohc

continuous time sync

mv -i /etc/ntp.conf /etc/ntp.conf.dist
sed '/^$/d;/^#/d;' /etc/ntp.conf.dist > /etc/ntp.conf
vi /etc/ntp.conf

server 0.ru.pool.ntp.org iburst
server 1.ru.pool.ntp.org iburst
server 2.ru.pool.ntp.org iburst
server 3.ru.pool.ntp.org iburst

chmod +x /etc/rc.d/rc.ntpd 
/etc/rc.d/rc.ntpd start

ready to go

timedatectl status
ntpstat
ntpq -p
#ntpq -pn

Notes.

  • jitter should be low, otherwise check the driftfile.
  • eventually add -x (Slew up to 600 seconds.) to the ntpd daemon arguments.

Refs.