Skip to content

Instantly share code, notes, and snippets.

@bspavel
Created December 4, 2020 18:56
Show Gist options
  • Save bspavel/770f5029e98bfc39049760b38b3c1cf0 to your computer and use it in GitHub Desktop.
Save bspavel/770f5029e98bfc39049760b38b3c1cf0 to your computer and use it in GitHub Desktop.
NTP client
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "Run script as ROOT please. (sudo !!!)"
exit
fi
#timedatectl list-timezones
#sudo timedatectl set-timezone <time zone>
#For example:
#sudo timedatectl set-timezone America/New_York
#sudo timedatectl set-timezone Europe/Paris
#sudo timedatectl set-timezone Australia/Sydney
#If you want to disable or enable the time synchronization, use these commands:
#sudo timedatectl set-ntp false
#sudo timedatectl set-ntp true
apt-get remove ntp ntpstat --purge
apt autoremove
sudo systemctl restart systemd-timesyncd
systemctl status systemd-timesyncd
timedatectl show-timesync
#ip - address of ntp server
printf "[Time]\nNTP=ip" > /etc/systemd/timesyncd.conf
timedatectl set-ntp true
systemctl enable --now systemd-timesyncd.service
systemctl restart systemd-timesyncd.service
systemctl status systemd-timesyncd.service
timedatectl status
timedatectl timesync-status
#sudo apt install ntpdate
#sudo ntpdate -q ip
#sudo service ntp stop
#sudo ntpdate ip
#sudo service ntp start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment