linux作为网站服务器的时候时间是很重要的数据,网站上的所有时间都来源于这个系统时间。那么一个准确的时间对于linux服务器来讲是最基本的!
由于硬件的误差,机器或多或少的根标准时间对不上,一个月的误差几秒到几分钟不等。对于服务器来说时间不准,会有很多麻烦。 所以最好是定时的从外界同步时间。
1.安装ntpdate:
如果你的linux系统有ntpdate这个命令就跳过次步骤。(centos)
yum install ntp
2.安装完了之后,你不要做什么配置,也不需要,直接测试一下:
[root@localhost ~]# ntpdate time.nist.gov

3.进入到crontab
[root@localhost ~]# crontab -e

4.增加命令*/10 * * * * ntpdate time.nist.gov #这是指每隔10分钟执行一次,如果时间频率不想这么高,可以调整这些 *