haixin3036 发表于 2018-10-19 13:38:58

How to Sync Your Linux Server Time with Network Time Servers (NTP)

  转载自https://www.howtogeek.com/tips/how-to-sync-your-linux-server-time-with-network-time-servers-ntp/

  Most servers are probably automatically configured to network time, but if you want to set it up for yourself, or want to change the servers that you are syncing to, here’s the quick article that shows you how to do it.
  Since I had to do this earlier today, I decided it would make a lot of sense to write it down for the next time that I need to do it. Yeah, this article is really just for me.
  First, you’ll need to install NTP if it isn’t already installed. For Debian or Ubuntu, that would be this command:
  sudo apt-get install ntp
  For Redhat or CentOS, you’ll need to use these commands to install ntp and enable it:
  yum install ntp
  systemctl enable ntpd
  Then you’ll want to edit the /etc/ntp.conf file, which is quite possibly already filled out for you.
  vi /etc/ntp.conf
  You’ll find a lot of lines in there, but the important ones are the server lines. You can get a list of server addresses at www.pool.ntp.org, find the preferred ones for your area, and then add them to the file. For my purposes, that meant:
  server 0.north-america.pool.ntp.org
  server 1.north-america.pool.ntp.org
  server 2.north-america.pool.ntp.org
  server 3.north-america.pool.ntp.org
  Then you’ll need to restart or start the NTPD service:
  /etc/init.d/ntpd restart
  If you want to update the time right now, you can stop the NTP service and then run the following command, swapping out your preferred server for pool.ntp.org.
  /usr/sbin/ntpdate pool.ntp.org
  Fairly simple.

页: [1]
查看完整版本: How to Sync Your Linux Server Time with Network Time Servers (NTP)