Friday, April 26, 2024

Linux VPS自动时间校准命令

很多VPS安装完成后,过了很久才发现时间不准这个问题。有些是由于本身就没有调整好准确的时间,而有些则是因为时差问题导致连日期都有错误。本文将讲解ntpdate这一网络自动校时工具的安装与使用方法。

其实Linux中有个ntp包可以自动校准时间,并且非常好用。

Debian系统安装NTP校时包:

apt-get install ntpdate

CentOS系统安装NTP校时包:

yum install ntp

校时命令:

ntpdate cn.pool.ntp.org

如果想每隔一定时间自动校时,只需将上面的命令加入至Cron就行了:

00 12 * * * /sbin/ntpdate cn.pool.ntp.org

* cn.pool.ntp.org是ntp网络授时组织的中国授时源

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.