当前位置: 首页 > news >正文

linux时间管理

文章目录

  • linux时间管理
    • 系统时间设置
      • date命令
      • tzselect命令
      • windows自动对时
      • 自动对时chronyd服务
    • 部署时间服务器
      • 服务端
      • 客户端

linux时间管理

系统时间设置

date命令

[root@server ~ 16:26:58]# date
2025年 09月 15日 星期一 16:42:21 CST
#修改时间
[root@server ~ 16:42:21]# date -s '2025-09-19'

tzselect命令

查询时区名称。

[root@server ~ 14:03:25]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.1) Africa2) Americas3) Antarctica4) Arctic Ocean5) Asia6) Atlantic Ocean7) Australia8) Europe9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 2
Please select a country.1) Anguilla		  19) Dominican Republic    37) Peru2) Antigua & Barbuda	  20) Ecuador		    38) Puerto Rico3) Argentina		  21) El Salvador	    39) St Barthelemy4) Aruba		  22) French Guiana	    40) St Kitts & Nevis5) Bahamas		  23) Greenland		    41) St Lucia6) Barbados		  24) Grenada		    42) St Maarten (Dutch)7) Belize		  25) Guadeloupe	    43) St Martin (French)8) Bolivia		  26) Guatemala		    44) St Pierre & Miquelon9) Brazil		  27) Guyana		    45) St Vincent
10) Canada		  28) Haiti		    46) Suriname
11) Caribbean NL	  29) Honduras		    47) Trinidad & Tobago
12) Cayman Islands	  30) Jamaica		    48) Turks & Caicos Is
13) Chile		  31) Martinique	    49) United States
14) Colombia		  32) Mexico		    50) Uruguay
15) Costa Rica		  33) Montserrat	    51) Venezuela
16) Cuba		  34) Nicaragua		    52) Virgin Islands (UK)
17) Curaçao		  35) Panama		    53) Virgin Islands (US)
18) Dominica		  36) Paraguay
#? 49
Please select one of the following time zone regions.1) Eastern (most areas)	      16) Central - ND (Morton rural)2) Eastern - MI (most areas)	      17) Central - ND (Mercer)3) Eastern - KY (Louisville area)    18) Mountain (most areas)4) Eastern - KY (Wayne)	      19) Mountain - ID (south); OR (east)5) Eastern - IN (most areas)	      20) MST - Arizona (except Navajo)6) Eastern - IN (Da, Du, K, Mn)      21) Pacific7) Eastern - IN (Pulaski)	      22) Alaska (most areas)8) Eastern - IN (Crawford)	      23) Alaska - Juneau area9) Eastern - IN (Pike)		      24) Alaska - Sitka area
10) Eastern - IN (Switzerland)	      25) Alaska - Annette Island
11) Central (most areas)	      26) Alaska - Yakutat
12) Central - IN (Perry)	      27) Alaska (west)
13) Central - IN (Starke)	      28) Aleutian Islands
14) Central - MI (Wisconsin border)   29) Hawaii
15) Central - ND (Oliver)

windows自动对时

在这里插入图片描述

自动对时chronyd服务

修改对齐时间为ntp.aliyun.com
[root@server ~ 13:57:59]# vim /etc/chrony.conf
[root@server ~ 14:01:16]# head /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
[root@server ~ 14:01:22]# systemctl restart chronyd
[root@server ~ 14:01:41]# ping ntp.aliyun.com
PING ntp.aliyun.com (203.107.6.88) 56(84) bytes of data.
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=1 ttl=128 time=125 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=2 ttl=128 time=130 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=3 ttl=128 time=128 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=4 ttl=128 time=128 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=5 ttl=128 time=126 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=6 ttl=128 time=127 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=7 ttl=128 time=123 ms
^C
--- ntp.aliyun.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6009ms
rtt min/avg/max/mdev = 123.402/127.220/130.118/2.134 ms
#查看对齐对象
[root@server ~ 14:03:18]# chronyc sources -v
210 Number of sources = 1.-- Source mode  '^' = server, '=' = peer, '#' = local clock./ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 203.107.6.88                  2   6    37    33    -73us[ -290us] +/-   74ms

部署时间服务器

chrony既可以作为客户端,也可以作为服务端(为客户端提供对时服务)。

服务端

[root@server ~ 14:22:11]# vim /etc/chrony.conf[root@server ~ 14:30:42]# tail -n 5 /etc/chrony.conf# Select which information is logged.
#log measurements statistics tracking
bindaddress 10.1.8.10# 配置监听地址
allow 10.1.8.0/24# 配置允许哪些网段主机同步
#重启服务
[root@server ~ 14:23:47]# systemctl restart chronyd

客户端

# 修改对时服务器
[root@client ~ 14:22:40]$ vim /etc/chrony.conf 
# 与单个服务器 10.1.8.10 对时
[root@client ~ 14:33:37]# head -n 10 /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 10.1.8.10 iburst# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift[root@client ~ 14:27:02]# systemctl restart chronyd
[root@client ~ 14:27:15]# chronyc sources -v
210 Number of sources = 1.-- Source mode  '^' = server, '=' = peer, '#' = local clock./ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? server.dyx.cloud              0   6     0     -     +0ns[   


文章转载自:

http://nRqurn54.xLndf.cn
http://UQuAfiLp.xLndf.cn
http://aQpxJRza.xLndf.cn
http://QYCjcAgF.xLndf.cn
http://lBgrn4DC.xLndf.cn
http://7eAk30yZ.xLndf.cn
http://IzLKCFkV.xLndf.cn
http://hT9aoVru.xLndf.cn
http://xpTSMSY1.xLndf.cn
http://mBkN2Fpx.xLndf.cn
http://djVUupdO.xLndf.cn
http://rQbLURrs.xLndf.cn
http://fzaITE57.xLndf.cn
http://YZO1F7FL.xLndf.cn
http://YIfQW4Nm.xLndf.cn
http://z0X6O2Sh.xLndf.cn
http://c0WZKb7d.xLndf.cn
http://d9YoU6Of.xLndf.cn
http://BzgIltKY.xLndf.cn
http://BVNuUyef.xLndf.cn
http://s3kejETt.xLndf.cn
http://t2FTTISM.xLndf.cn
http://FG4dGuE7.xLndf.cn
http://rbdCufUk.xLndf.cn
http://gtVFrpC8.xLndf.cn
http://rgCsdaSj.xLndf.cn
http://5CyTrOSB.xLndf.cn
http://N10Ah0YF.xLndf.cn
http://r02LJ0jc.xLndf.cn
http://7PeuoZ4F.xLndf.cn
http://www.dtcms.com/a/384897.html

相关文章:

  • 第2章 语言模型:自然语言处理的基石
  • 汽车电子电气架构 --- 新趋势下的挑战与技术
  • 地铁站电子钟:NTP实时校准时间
  • 【数据集】2025年国家自然科学基金立项名单(经管类)
  • Elastic APM 2025 新特性:Tail-based Sampling 和 GenAI 优化
  • 如何解决 pip install 安装报错 ModuleNotFoundError: No module named ‘sklearn’ 问题
  • 《二战系统分析师》第五章总结
  • 机器学习中的距离总结
  • MongoDB集群开发完全指南:从原理到实践
  • apache phoenix sql 命令大全详解
  • python 读取大文件优化示例
  • 布草洗涤厂设备租赁押金原路退回系统—东方仙盟
  • JAVASCRIPT 前端数据库-V9--仙盟数据库架构-—仙盟创梦IDE
  • 开源AI大模型、AI智能名片与S2B2C商城小程序:从“不出现=不存在”到“精准存在”的数字化转型路径
  • LNMP环境搭建:高效Web服务器指南
  • ACP(三):让大模型能够回答私域知识问题
  • Angle-Based SLAM on 5G mmWave Systems: Design, Implementation, and Measurement
  • 京瓷1025打印机打印有底灰简单处理
  • UE5 播放关卡时,将渲染画面的相机转变为关卡序列中的相机
  • JavaSE 异常
  • Unity Excel数据导入工具
  • 镭神C16在Ubuntu下的连接和驱动安装教程
  • 如何在qt中配置libssh
  • 使用 Spring Boot 3.x 集成 Kafka 并在 Kubernetes 上部署的全流程指南
  • 记录本地安装anaconda pytorch python
  • 关于机器学习中的各种“学习”
  • Parlant框架深度技术解析:革命性AI代理行为建模引擎
  • 疯狂星期四文案网第68天运营日记
  • RabbitMQ 消息路由与交换机机制
  • 月视图,周视图,日视图