linux下时间同步的两种方法分享
2015-06-29 10:03
543 查看
方法1:
与一个已知的时间服务器同步
代码如下:
ntpdate time.nist.gov
其中
time.nist.gov 是一个时间服务器.
删除本地时间并设置时区为上海
代码如下:
rm -rf /etc/localtime
ln -s
/usr/share/zoneinfo/Asia/Shanghai
/etc/localtime
方法2:
linux自动同步时间
vi
/etc/crontab
加上一句:
复制代码
代码如下:
00 0 1 * * root rdate -s
time.nist.gov
配置时间服务器配置(192.168.10.1)
代码如下:
1)、# rpm -ivh
ntp-4.1.2-4.EL3.1.i386.rpm
2)、# vi /etc/ntp.conf
注释一行:
restrict default ignore
加入一行:
代码如下:
restrict 192.168.10.0 mask 255.255.255.0
notrust nomodify notrap
3)、# vi
/etc/ntp/step-tickers
加入一行:
pool.ntp.org
这样每次ntpd启动时,会自动连接该国际标准时间服务器;
4)、# service ntpd start
5)、# netstat -an |grep 123
确保该端口以udp方式开放
时间客户端配置(192.168.10.2)
1)、# ntpdate 192.168.10.2
应该显示同步成功
2)、# crond
-e
加入
代码如下:
0-59/10 * * * * /usr/sbin/ntpdate
192.168.10.1
每隔10分钟同步一次时间
与一个已知的时间服务器同步
代码如下:
ntpdate time.nist.gov
其中
time.nist.gov 是一个时间服务器.
删除本地时间并设置时区为上海
代码如下:
rm -rf /etc/localtime
ln -s
/usr/share/zoneinfo/Asia/Shanghai
/etc/localtime
方法2:
linux自动同步时间
vi
/etc/crontab
加上一句:
复制代码
代码如下:
00 0 1 * * root rdate -s
time.nist.gov
配置时间服务器配置(192.168.10.1)
代码如下:
1)、# rpm -ivh
ntp-4.1.2-4.EL3.1.i386.rpm
2)、# vi /etc/ntp.conf
注释一行:
restrict default ignore
加入一行:
代码如下:
restrict 192.168.10.0 mask 255.255.255.0
notrust nomodify notrap
3)、# vi
/etc/ntp/step-tickers
加入一行:
pool.ntp.org
这样每次ntpd启动时,会自动连接该国际标准时间服务器;
4)、# service ntpd start
5)、# netstat -an |grep 123
确保该端口以udp方式开放
时间客户端配置(192.168.10.2)
1)、# ntpdate 192.168.10.2
应该显示同步成功
2)、# crond
-e
加入
代码如下:
0-59/10 * * * * /usr/sbin/ntpdate
192.168.10.1
每隔10分钟同步一次时间
相关文章推荐
- C语言实现Linux下的socket文件传输实例
- linux 驱动开发 Invalid module format 错误解决方法
- CentOS之NTP服务器配置
- Linux内核中读写文件数据的方法
- Linux man命令数字含义
- linux驱动current,引用当前进程,及task_struct
- CentOS 配置LAMP环境
- 查看SELinux状态
- Linux系统递归生成目录中文件的md5的方法
- 【原创】记一个Java GUI程序(原目标OS是Windows)“移植”到Linux的过程
- linux运行级别
- linux 查找文件关键字
- MySQL在Linux系统中隐藏命令行中的密码的方法
- linux上使用命令制作u盘启动盘
- Linux伙伴系统(一)--伙伴系统的概述
- 《深度实践嵌入式Linux系统移植》
- Linux管理员必须知道的sudo命令
- 通过ulimit改善linux系统性能(摘自IBM)
- Linux中CPU与内存性能监测
- 简介Linux中cp和mv搭配{,}在shell当中的用法