更新 Linux 服务器时间

Linux ntp About 553 words

查看时间

命令:

date

输出:

Wed Jul 17 15:49:15 CST 2019

更新时间

命令:

sudo ntpdate 0.asia.pool.ntp.org

输出:

17 Jul 15:57:27 ntpdate[30572]: adjust time server 133.243.238.163 offset -0.030614 sec

the NTP socket is in use, exiting

ntpd服务已启动,不用再更新时间。

查看ntpd服务是否启动:

ps aux | grep ntpd

启动 ntpd 服务

-c:指定配置文件,默认/etc/ntp.conf

-p:指定记录ntpd进程ID的文件

-g:通常如果系统时间与服务器时间差别太大(默认是1000秒),ntpd则会自动退出,并记录到日志文件。该选项允许不理会该门限。但该命令只能有效一次,如果第一次同步后,客户端的时差依然超过门限,则ntpd会自动退出,并记录在日志文件。

ntpd -p /var/run/ntpd.pid -g 

查看硬件时间

hwclock

hwclock -r

hwclock --show

同步硬件时间

hwclock –w

hwclock --systohc
Views: 2,910 · Posted: 2019-07-17

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓
Today On History
Browsing Refresh