Linux同步时间方法CentOS同步时间方法 Linux系统

admin 2017-07-31 4592

一、在需要集中记录服务器日志的环境中,时间同步那是相当的重要的。本文为大家介绍同步linux时间的方法,供大家参考


1、如果不支持ntpdate命令,需要先安装ntpdate工具

1
yum -y install ntp ntpdate


2、删除本地时间并设置时区为中国上海

1
2
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


3、设置系统时间与网络时间同步

1
ntpdate ntp.api.bz

提供5个备用地址

1
2
3
4
5
6
7
8
9
ntpdate cn.pool.ntp.org
 
ntpdate 0.cn.pool.ntp.org
 
ntpdate 1.cn.pool.ntp.org
 
ntpdate 2.cn.pool.ntp.org
 
ntpdate 3.cn.pool.ntp.org

或者(中国国家授时中心)

1
ntpdate -u 210.72.145.44

备注:--u参数可以越过防火墙与主机同步;


4、将系统时间写入硬件时间

1
hwclock --systohc


5、查看系统时间的命令

1
date

6、查看硬件时间的命令

1
hwclock


二、手动设置时间方法

1、手动设置时间命令【date –set(月/日/年 时:分:秒)】

1
例如: date set “7/31/17 23:59:59”
最新回复 (0)
全部楼主
    • MSDN,我告诉你(中文站)
      2
        登录 注册 获取赞助码
返回