Wednesday, April 24, 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.