Linux关于时间的设置及简单解释

关于系统时间的,系统存在一个人硬件时间和软件的时间,以我使用的Rocky(Linux)系统为例子,在开机的时候按下F2键,弹出BIOS界面,在这里我们可以看到

启动好后我们使用命令clock也可以获取他的硬件时间

我们用date则是获取他的软件时间,这两者是有区别的

现在我们模拟下改下时间date +月日小时分年.秒(即2020/10/30 08:30:30)

现在的硬件时间可以用clock

现在我们把硬件时间为基准修改错误的软件时间使用clock -s 命令即可修正

 把软件时间为基准修改错误的硬件时间使用clock -w命令即可修正

 使用 cal 2022命令可以看到2022年整年的日历

补充小知识:用cal 9 1752查看的时候发现中间消失了11天。(有兴趣可以看下)

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Linux系统中的时间设置配置文件是/etc/chrony.conf。可以通过编辑该文件来配置时间服务器和客户端的时间同步。具体步骤如下: 1. 查看/etc/chrony.conf文件,可以使用以下命令: ```shell cat /etc/chrony.conf ``` 2. 编辑/etc/chrony.conf文件,可以使用以下命令: ```shell vi /etc/chrony.conf ``` 3. 在/etc/chrony.conf文件中,可以进行以下配置: - 取消网络服务器作为时间同步源的配置,添加本地时间服务器。 - 设置允许与时间服务器同步时间的客户端网段。 - 设置时间服务器允许使用本地时间作为标准时间进行同步。 例如,以下是一个简单的/etc/chrony.conf文件配置示例: ```shell # 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 # Ignore stratum in source selection. stratumweight 0 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Enable kernel RTC synchronization. rtcsync # In first three updates step the system clock instead of slew makestep 1 -1 # Allow NTP client access from local network. allow 192.168.0.0/16 # Serve time even if not synchronized to a time source. local stratum 10 # Specify file containing keys for NTP authentication. keyfile /etc/chrony.keys # Specify directory for log files. logdir /var/log/chrony ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT阿科

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值