打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Debian/Ubuntu 时区和自动校时设置

Debian/Ubuntu 时区和自动校时设置

NTP 是通过网络自动校时的一种 TCP/IP 协议。Debian/Ubuntu 中有两种方式实现时间同步:ntpdate 和 ntpd,前者为一天调整一次时间,后者 ntpd 为守护进程,可以持续不断地调整时间。个人推荐使用 ntpd,它实际占用资源是很小的。

一、设置服务器时区

如果是美国VPS,那么时区要首先设置,不然哪怕再精准的时间也是白搭。我一般使用 tzconfig 或 tzselect 工具来设置时区。

1
tzselect
123
cat >>~/.profile<<EOFTZ='Asia/Shanghai'; export TZEOF
12
rm -rf /etc/localtimecp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

二、设置时间同步服务器

方法一:ntpdate 方式

12345
apt-get install -y ntpdate #安装vim /etc/cron.daily/ntpdate #添加下面一行,每天同步。ntpdate ntp.ubuntu.com cn.pool.ntp.orgchmod 755 /etc/cron.daily/ntpdate #修改权限ntpdate -d cn.pool.ntp.org #立即同步时间

方法二:ntpd 方式

1234
apt-get install -y ntpd #安装vim /etc/ntp.conf #添加下面一行server cn.pool.ntp.org/etc/init.d/ntp restart #重启

以下适用于 debian

1234567
apt-get install -y ntpvim /etc/ntp.conf #修改为下面几行server 0.debian.pool.ntp.org iburst dynamicserver 1.debian.pool.ntp.org iburst dynamicserver 2.debian.pool.ntp.org iburst dynamicserver 3.debian.pool.ntp.org iburst dynamic/etc/init.d/ntp restart #重启

参考资料:

1. http://people.ubuntu.com/~happyaron/ubuntu-docs-test/lucid/serverguide/zh_CN/NTP.html
2. http://www.cyberciti.biz/faq/debian-ubuntu-linux-install-ntpd/
3. http://e-boy.cn/artical/view/84303/

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
大数据技术学习分享:Hadoop集群同步
linux同步时间的三种方法
centos7配置NTP时间服务器
Linux的NTP配置总结
网络时间服务和chrony
ntpd时钟同步服务
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服