I have CentOS machine and each time I've noticed that the server loses correct time after a while. It is usually behind by several minutes after time passes from having manually set the correct time. Is there a mechanism whereby I can update the server with the time from a specific time server?
10 Answers
Use the ntp daemon. Run yum install ntp and ensure that the service is started via ntsysv or chkconfig ntpd on.
To get an immediate sync, run ntpdate time.apple.com (or something similar).
- 201,205
You need to install and configure ntp.
yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
service ntpd start
should get things set up and running. You may find that the ntp package is already installed and just needs configuring.
- 117,122
Yes.
yum install ntp
chkconfig ntpd on
Do an initial sync, with
ntpdate pool.ntp.org
and start the time daemon with:
/etc/init.d/ntpd start
- 27,578
You'll need to configure ntpd for the server. I suspect it is already installed but needs to be configured. Note: if it is a virtual server, you probably have the option of syncing with the virtual host.
- 6,452
For centos 7.x installation:
yum install ntp
systemctl enable ntpd
initial sync, with:
ntpdate pool.ntp.org
start the daemon with:
systemctl start ntpd
- 131
In the case of Centos 8, I just start/enble chronyd like below:
systemctl start chronyd
systemctl enable chronyd
- 133
Basically there are two ways. NTP daemon and the ntpdate command. The most important difference is that ntpdate will synchronize the time at once even though it means that the system time will change. On the other hand NTP daemon will take care of the time synchronization and it will adjust the time by small steps - you can think about it like slowing down/speeding up the time of the computer to synchronize it to the correct time. Thats why people suggest to do the initial synchronization by ntpdate and then leave it to ntp daemon.
- 620
Yea I'd use NTP, install ntp with yum and turn it on.
yum install ntp
chkconfig ntpd on
Then sync it to any ntp server of your liking with the ntpdate command
- 16,990
Also if using CPanel like I was and had this issue. I think using rdate. Changing to ntpd as per above fixes all issues with email, especially dovecot,etc.
- 1