LMLPHP后院

debian datetime adjustment技术

maybe yes 发表于 2024-09-02 09:24

debian 时间同步

Linux de 5.10.0-23-amd64 #1 SMP Debian 5.10.179-1 (2023-05-12) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Sep  1 20:48:42 2024 from 192.168.11.1


root@de:~# timedatectl status
               Local time: Sun 2024-09-01 12:04:25 EDT
           Universal time: Sun 2024-09-01 16:04:25 UTC
                 RTC time: Sun 2024-09-01 20:58:18
                Time zone: US/Eastern (EDT, -0400)
System clock synchronized: no
              NTP service: n/a
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.


root@de:~# chronyd
-bash: chronyd: command not found
root@de:~# apt install chrony
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  dnsutils networkd-dispatcher
The following NEW packages will be installed:
  chrony
0 upgraded, 1 newly installed, 0 to remove and 101 not upgraded.
Need to get 287 kB of archives.
After this operation, 644 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 chrony amd64 4.0-8+deb11u2 [287 kB]
Fetched 287 kB in 12s (24.5 kB/s)                                                                                                                                                     
Selecting previously unselected package chrony.
(Reading database ... 33668 files and directories currently installed.)
Preparing to unpack .../chrony_4.0-8+deb11u2_amd64.deb ...
Unpacking chrony (4.0-8+deb11u2) ...
Setting up chrony (4.0-8+deb11u2) ...

Creating config file /etc/chrony/chrony.conf with new version

Creating config file /etc/chrony/chrony.keys with new version
dpkg-statoverride: warning: --update given but /var/log/chrony does not exist
Created symlink /etc/systemd/system/chronyd.service → /lib/systemd/system/chrony.service.
Created symlink /etc/systemd/system/multi-user.target.wants/chrony.service → /lib/systemd/system/chrony.service.


root@de:~# timedatectl status
               Local time: Sun 2024-09-01 21:07:59 EDT
           Universal time: Mon 2024-09-02 01:07:59 UTC
                 RTC time: Sun 2024-09-01 21:01:56
                Time zone: US/Eastern (EDT, -0400)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
root@de:~# chronyd
Another chronyd may already be running (pid=4080632), check /run/chrony/chronyd.pid
root@de:~# chronyd -Q
2024-09-02T01:09:10Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2024-09-02T01:09:10Z Disabled control of system clock
2024-09-02T01:09:10Z Using right/UTC timezone to obtain leap second data
2024-09-02T01:09:15Z System clock wrong by 0.008633 seconds (ignored)
2024-09-02T01:09:15Z chronyd exiting


root@de:~# date
Mon 02 Sep 2024 09:09:18 AM CST
root@de:~# chronyd -q
2024-09-02T01:10:08Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2024-09-02T01:10:08Z Fatal error : Another chronyd may already be running (pid=4080632), check /run/chrony/chronyd.pid
root@de:~# timedatectl status
               Local time: Sun 2024-09-01 21:10:41 EDT
           Universal time: Mon 2024-09-02 01:10:41 UTC
                 RTC time: Sun 2024-09-01 21:10:41
                Time zone: US/Eastern (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.


root@de:~# chronyd -q
2024-09-02T01:13:18Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2024-09-02T01:13:18Z Fatal error : Another chronyd may already be running (pid=4080632), check /run/chrony/chronyd.pid
root@de:~# chronyd -Q
2024-09-02T01:13:22Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2024-09-02T01:13:22Z Disabled control of system clock
2024-09-02T01:13:22Z Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/chrony.drift
2024-09-02T01:13:22Z Using right/UTC timezone to obtain leap second data
2024-09-02T01:13:27Z System clock wrong by -0.002952 seconds (ignored)
2024-09-02T01:13:27Z chronyd exiting


root@de:~# ps aux | grep chrony
_chrony  4080632  0.0  0.0  19032  3684 ?        S    09:07   0:00 /usr/sbin/chronyd -F 1
_chrony  4080633  0.0  0.0  10840  2740 ?        S    09:07   0:00 /usr/sbin/chronyd -F 1
root     4082093  0.0  0.0   6240   708 pts/0    S+   09:13   0:00 grep chrony



root@de:~# chronyd --help
Usage: chronyd [OPTION]... [DIRECTIVE]...

Options:
  -4		Use IPv4 addresses only
  -6		Use IPv6 addresses only
  -f FILE	Specify configuration file (/etc/chrony/chrony.conf)
  -n		Don't run as daemon
  -d		Don't run as daemon and log to stderr
  -l FILE	Log to file
  -L LEVEL	Set logging threshold (0)
  -p		Print configuration and exit
  -q		Set clock and exit
  -Q		Log offset and exit
  -r		Reload dump files
  -R		Adapt configuration for restart
  -s		Set clock from RTC
  -t SECONDS	Exit after elapsed time
  -u USER	Specify user (_chrony)
  -U		Don't check for root
  -F LEVEL	Set system call filter level (0)
  -P PRIORITY	Set process priority (0)
  -m		Lock memory
  -x		Don't control clock
  -v, --version	Print version and exit
  -h, --help	Print usage and exit
root@de:~# 
root@de:~# systemctl status datetime
Unit datetime.service could not be found.
root@de:~# systemctl status chronyy
Unit chronyy.service could not be found.
root@de:~# systemctl status chrony
● chrony.service - chrony, an NTP client/server
     Loaded: loaded (/lib/systemd/system/chrony.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-09-02 00:07:56 CST; 9h ago
       Docs: man:chronyd(8)
             man:chronyc(1)
             man:chrony.conf(5)
    Process: 4080630 ExecStart=/usr/sbin/chronyd $DAEMON_OPTS (code=exited, status=0/SUCCESS)
   Main PID: 4080632 (chronyd)
      Tasks: 2 (limit: 18883)
     Memory: 1.4M
        CPU: 33ms
     CGroup: /system.slice/chrony.service
             ├─4080632 /usr/sbin/chronyd -F 1
             └─4080633 /usr/sbin/chronyd -F 1

Sep 02 00:07:56 de systemd[1]: Starting chrony, an NTP client/server...
Sep 02 00:07:56 de chronyd[4080632]: chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
Sep 02 00:07:56 de chronyd[4080632]: Using right/UTC timezone to obtain leap second data
Sep 02 00:07:56 de chronyd[4080632]: Loaded seccomp filter
Sep 02 00:07:56 de systemd[1]: Started chrony, an NTP client/server.
Sep 02 00:08:02 de chronyd[4080632]: Selected source 110.42.98.138 (2.debian.pool.ntp.org)
Sep 02 00:08:02 de chronyd[4080632]: System clock wrong by 32397.260653 seconds
Sep 02 09:07:59 de chronyd[4080632]: System clock was stepped by 32397.260653 seconds
Sep 02 09:07:59 de chronyd[4080632]: System clock TAI offset set to 37 seconds
Sep 02 09:08:01 de chronyd[4080632]: Selected source 202.112.29.82 (2.debian.pool.ntp.org)


root@de:~# timedatectl status
               Local time: Sun 2024-09-01 21:18:01 EDT
           Universal time: Mon 2024-09-02 01:18:01 UTC
                 RTC time: Sun 2024-09-01 21:18:01
                Time zone: US/Eastern (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.


root@de:~# timedatectl set-local-rtc 0
root@de:~# timedatectl 
               Local time: Sun 2024-09-01 21:41:41 EDT
           Universal time: Mon 2024-09-02 01:41:41 UTC
                 RTC time: Mon 2024-09-02 01:41:41
                Time zone: US/Eastern (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
root@de:~# date
Mon 02 Sep 2024 09:41:48 AM CST
root@de:~# hwclock 
2024-09-02 05:43:22.743599+08:00
root@de:~# date
Mon 02 Sep 2024 09:43:26 AM CST
root@de:~# hwclock --show
2024-09-02 05:44:09.791545+08:00
root@de:~# hwclock --systohc
root@de:~# hwclock --show
2024-09-02 09:45:16.177046+08:00
root@de:~# hwclock
2024-09-02 09:45:21.937260+08:00
root@de:~# date
Mon 02 Sep 2024 09:45:23 AM CST
2024-11-19 02:48:23 1731955703 0.362088