Linux修改时间日期

参考文章

root@k8s-master1:~# timedatectl
               Local time: Sun 2025-05-04 12:44:13 CST
           Universal time: Sun 2025-05-04 04:44:13 UTC
                 RTC time: Fri 2025-05-02 16:21:25
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
root@k8s-master1:~# timedatectl  set-ntp 0
root@k8s-master1:~# timedatectl set-time "2023-09-13 18:54:30"
Failed to set time: Previous request is not finished, refusing.
root@k8s-master1:~# timedatectl set-time "2023-09-13 18:54:30"
root@k8s-master1:~# timedatectl
               Local time: Wed 2023-09-13 18:54:34 CST
           Universal time: Wed 2023-09-13 10:54:34 UTC
                 RTC time: Wed 2023-09-13 10:54:35
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
root@k8s-master1:~# timedatectl  set-ntp 0
root@k8s-master1:~# timedatectl set-time "2023-09-13 18:54:30"
root@k8s-master1:~# timedatectl
               Local time: Wed 2023-09-13 18:54:34 CST
           Universal time: Wed 2023-09-13 10:54:34 UTC
                 RTC time: Wed 2023-09-13 10:54:35
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
root@k8s-master1:~# timedatectl set-time 2025-05-04
root@k8s-master1:~# timedatectl
               Local time: Sun 2025-05-04 00:00:01 CST
           Universal time: Sat 2025-05-03 16:00:01 UTC
                 RTC time: Sat 2025-05-03 16:00:01
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
root@k8s-master1:~# timedatectl set-time 12:00:00
root@k8s-master1:~# timedatectl
               Local time: Sun 2025-05-04 12:00:01 CST
           Universal time: Sun 2025-05-04 04:00:01 UTC
                 RTC time: Sun 2025-05-04 04:00:01
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local


root@k8s-master1:~# cat /etc/systemd/timesyncd.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the timesyncd.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See timesyncd.conf(5) for details.

[Time]
NTP=ntp.aliyun.com
FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#ConnectionRetrySec=30
#SaveIntervalSec=60
root@k8s-master1:~# systemctl daemon-reload; systemctl restart systemd-timesyncd.service

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值