linux服务器校对和手动修改时间

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/XiaHeShun/article/details/84982765

1.手动校对时间

date -s "20190614 12:00:00"
输入这条命令系统时间会设置为2019年06月14日12点00分。
修改之后你可以输入date命令查询当前时间。

2.服务器校对时间

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

Debian系统安装NTP校时包: 
1 apt-get install ntpdate

CentOS系统安装NTP校时包: 
1 yum install ntp

校时命令: 
1 ntpdate cn.pool.ntp.org

如果想每隔一定时间自动校时,只需将上面的命令加入至Cron就行了: 
1 00 12 * * * /sbin/ntpdate cn.pool.ntp.org

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

猜你喜欢

转载自blog.csdn.net/XiaHeShun/article/details/84982765