Ubuntu 18.04 :
sudo apt install ntp
Serveur WCT :
vim /etc/ntp.conf
server timeserver.wabtec.com restrict timeserver.wabtec.com mask 255.255.255.255 nomodify notrap noquery server 10.129.20.20
service ntpd stop
service ntpd start
service ntpd restart
cat /var/log/messages
Sur EL7 (octal_V15)
root@wctsrv0057:~# timedatectl Local time: Tue 2019-10-01 15:30:45 CEST Universal time: Tue 2019-10-01 13:30:45 UTC RTC time: Tue 2019-10-01 12:24:05 Time zone: Europe/Paris (CEST, +0200) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2019-03-31 01:59:59 CET Sun 2019-03-31 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2019-10-27 02:59:59 CEST Sun 2019-10-27 02:00:00 CET
root@wctsrv0057:~# timedatectl set-ntp false
root@wctsrv0057:~# timedatectl Local time: Tue 2019-10-01 15:35:05 CEST Universal time: Tue 2019-10-01 13:35:05 UTC RTC time: Tue 2019-10-01 12:28:25 Time zone: Europe/Paris (CEST, +0200) NTP enabled: no NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2019-03-31 01:59:59 CET Sun 2019-03-31 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2019-10-27 02:59:59 CEST Sun 2019-10-27 02:00:00 CET
root@wctsrv0057:~# systemctl enable ntpd.service
Pour voir la date et l’heure actuelle
date
Pour changer l’heure
date -s « 09:56:00 »
Pour changer le jour
date -s « 2011-03-22 »
Mise à jour automatique de l’heure
Ajouter le service ntp
sous Ubuntu ou Debian
sudo apt-get install ntp
sous Redhat ou centos
yum install ntp
Lancer le service
sudo service ntpd start
ou
sudo service ntpd restart
sudo service ntp start
ou
sudo service ntp restart
ps -ef | grep ntp
vi /etc/ntp.conf
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# You do need to talk to an NTP server or two (or three).
#server ntp.ubuntu.com
#server 10.20.112.64
server pft.ft.grp
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that « restrict » applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don’t allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
Par défault on a :
/etc/init.d/ntp
/etc/rc1.d/K77ntp
/etc/rc2.d/S23ntp
/etc/rc3.d/S23ntp
/etc/rc4.d/S23ntp
/etc/rc5.d/S23ntp
ln -s ../init.d/ntp /etc/rc1.d/K77ntp
ln -s ../init.d/ntp /etc/rc2.d/S23ntp
ln -s ../init.d/ntp /etc/rc3.d/S23ntp
ln -s ../init.d/ntp /etc/rc4.d/S23ntp
ln -s ../init.d/ntp /etc/rc5.d/S23ntp