Centos5, 6, 以及Ubuntu18.04下更改系统时间和时区
2023-03-07 09:42:49 时间
http://www.namhuy.net/2435/how-to-change-date-time-timezone-on-centos-6.html
查看日期(使用 -R 参数会以数字显示时区)
$date
选择时区, 用当地的时区文件覆盖默认的, 这个在Ubuntu18.04下同样有效
cd /usr/share/zoneinfo/Asia/ sudo cp Shanghai /etc/localtime
修改时间
sudo date -s "20150514 18:07:00"
硬件时间操作
#查看硬件时间 sudo /sbin/clock --show #将系统时间保存至硬件 sudo /sbin/clock --systohc
#使用硬件时间, 将硬件时间更新到系统
sudo /sbin/clock --hctosys
安装ntp, 之后同步系统时间
sudo yum install ntp ntpdate pool.ntp.org
如果出现 sudo: timestamp too far in the future 错误, 使用 sudo -k 清理下当前会话时间
配置NTP时间同步
Centos6
检查ntpd服务是否已经运行 service ntpd status
检查ntpd服务配置文件 /etc/ntp.conf, 修改其中的 Use public servers 这部分, 将其修改为自己的ntp服务器, 或公用的ntp服务器
#restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). server 192.168.16.1 prefer server 0.pool.ntp.org server 1.pool.ntp.org server 2.pool.ntp.org server 3.pool.ntp.org
查看ntp服务器列表, 如果上面的配置正确, 可以通过ntpq -p命令查看ntp服务器状态
# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== WNDR3800.lan 192.36.143.153 3 u 12 64 1 0.488 2175.86 0.000 ntp1.flashdance .INIT. 16 u - 64 0 0.000 0.000 0.000 ntp8.flashdance 192.36.143.150 2 u 9 64 1 306.020 2159.29 0.000 tick.ntp.infoma .INIT. 16 u - 64 0 0.000 0.000 0.000 ntp6.flashdance 192.36.143.150 2 u 7 64 1 289.320 2167.42 0.000
相关文章
- 在 Go 里用 CGO?这 7 个问题你要关注!
- 9款优秀的去中心化通讯软件 Matrix 的客户端
- 求职数据分析,项目经验该怎么写
- 在OKR中,我看到了数据驱动业务的未来
- 火山引擎云原生大数据在金融行业的实践
- OpenHarmony富设备移植指南(二)—从postmarketOS获取移植资源
- 《数据成熟度指数》报告:64%的企业领袖认为大多数员工“不懂数据”
- OpenHarmony 小型系统兼容性测试指南
- 肯睿中国(Cloudera):2023年企业数字战略三大趋势预测
- 适用于 Linux 的十大命令行游戏
- GNOME 截图工具的新旧截图方式
- System76 即将推出的 COSMIC 桌面正在酝酿大变化
- 2GB 内存 8GB 存储即可流畅运行,Windows 11 极致精简版系统 Tiny11 发布
- 迎接 ecode:一个即将推出的具有全新图形用户界面框架的现代、轻量级代码编辑器
- loongarch架构介绍(三)—地址翻译
- Go 语言怎么解决编译器错误“err is shadowed during return”?
- 敏捷:可能被开发人员遗忘的部分
- Denodo预测2023年数据管理和分析的未来
- 利用数据推动可持续发展
- 在 Vue3 中实现 React 原生 Hooks(useState、useEffect),深入理解 React Hooks 的