Dual boot Windows time inconsistency #27

Open
opened 2024-06-10 19:22:21 +02:00 by Benjamin_Loison · 31 comments
sudo date -s "$(wget -qSO- --max-redirect=0 duckduckgo.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

Source: Stack Exchange

is a workaround.

man date
Output:
       -s, --set=STRING
              set time described by STRING
man wget
Output:
...
       -O file
       --output-document=file
           The documents will not be written to the appropriate files, but all
           will be concatenated together and written to file.  If - is used as
           file, documents will be printed to standard output, disabling  link
           conversion.  (Use ./- to print to a file literally named -.)

           Use of -O is not intended to mean simply "use the name file instead
           of  the  one  in  the  URL;"  rather,  it  is  analogous  to  shell
           redirection: wget -O file http://foo is intended to work like  wget
           -O - http://foo > file; file will be truncated immediately, and all
           downloaded content will be written there.

           For  this  reason,  -N (for timestamp-checking) is not supported in
           combination with -O: since file is always newly  created,  it  will
           always  have a very new timestamp. A warning will be issued if this
           combination is used.

           Similarly, using -r or -p with -O may not work as you expect:  Wget
           won't  just  download  the first file to file and then download the
           rest to their normal names: all downloaded content will  be  placed
           in file. This was disabled in version 1.11, but has been reinstated
           (with  a  warning)  in  1.11.2,  as there are some cases where this
           behavior can actually have some use.

           A combination with -nc is only accepted if the  given  output  file
           does not exist.

           Note  that a combination with -k is only permitted when downloading
           a single document, as  in  that  case  it  will  just  convert  all
           relative URIs to external ones; -k makes no sense for multiple URIs
           when  they're all being downloaded to a single file; -k can be used
           only when the output is a regular file.
...
       -S
       --server-response
           Print the headers sent by HTTP servers and responses  sent  by  FTP
           servers.
...
       -q
       --quiet
           Turn off Wget's output.
...

Tracked at Benjamin_Loison/windows/issues/14.

+20

```bash sudo date -s "$(wget -qSO- --max-redirect=0 duckduckgo.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z" ``` Source: Stack Exchange is a workaround. ```bash man date ``` <details> <summary>Output:</summary> ``` -s, --set=STRING set time described by STRING ``` </details> ```bash man wget ``` <details> <summary>Output:</summary> ``` ... -O file --output-document=file The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If - is used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally named -.) Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all downloaded content will be written there. For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it will always have a very new timestamp. A warning will be issued if this combination is used. Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download the rest to their normal names: all downloaded content will be placed in file. This was disabled in version 1.11, but has been reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use. A combination with -nc is only accepted if the given output file does not exist. Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all relative URIs to external ones; -k makes no sense for multiple URIs when they're all being downloaded to a single file; -k can be used only when the output is a regular file. ... -S --server-response Print the headers sent by HTTP servers and responses sent by FTP servers. ... -q --quiet Turn off Wget's output. ... ``` </details> Tracked at [Benjamin_Loison/windows/issues/14](https://codeberg.org/Benjamin_Loison/windows/issues/14). +20
Author
Owner

I executed above command while being connected to Shotbow and got after about an hour:

image

Happened again maybe when I sent a chat message.

I executed above command while being connected to Shotbow and got after about an hour: ![image](/attachments/de4440c5-f8c4-498b-b991-ff6c7c2e2dd5) Happened again maybe when I sent a chat message.
171 KiB
Author
Owner

Without sudo:

date: cannot set date: Operation not permitted
Without `sudo`: ``` date: cannot set date: Operation not permitted ```
Author
Owner

Cannot the server return an arbitrary value, hence run as root an arbitrary command? Maybe not thanks to "$(...)".

Cannot the server return an arbitrary value, hence run as `root` an arbitrary command? Maybe not thanks to `"$(...)"`.
Author
Owner
Related to [Benjamin-Loison/gitea/issues/117](https://github.com/Benjamin-Loison/gitea/issues/117).
Author
Owner
Maybe related to [Benjamin-Loison/gitea/issues/118](https://github.com/Benjamin-Loison/gitea/issues/118).
Author
Owner
Related to [Benjamin_Loison/Debian/issues/81](https://codeberg.org/Benjamin_Loison/Debian/issues/81).
Author
Owner

Maybe face a similar issue on my Debian 12 GNOME work laptop as it has a Windows 11 and Ubuntu 24.04.1 as well.

date
Sun Dec  1 08:06:43 PM CET 2024

while on my Fairphone 4 Termux:

date
Sun Dec  1 19:08:38 CET 2024
sudo date -s "$(wget -qSO- --max-redirect=0 duckduckgo.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
Sun Dec  1 07:10:00 PM CET 2024
date
Sun Dec  1 07:10:18 PM CET 2024

as far as I experienced it does not hold for long.

Maybe face a similar issue on my Debian 12 GNOME work laptop as it has a Windows 11 and Ubuntu 24.04.1 as well. ```bash date ``` ``` Sun Dec 1 08:06:43 PM CET 2024 ``` while on my Fairphone 4 Termux: ``` date ``` ``` Sun Dec 1 19:08:38 CET 2024 ``` ```bash sudo date -s "$(wget -qSO- --max-redirect=0 duckduckgo.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z" ``` ``` Sun Dec 1 07:10:00 PM CET 2024 ``` ```bash date ``` ``` Sun Dec 1 07:10:18 PM CET 2024 ``` as far as I experienced it does not hold for long.
Author
Owner

I enabled Automatic Time Zone and manually correct Date & Time again, let us see if the see issue is raised again at some point.

I enabled *Automatic Time Zone* and manually correct *Date & Time* again, let us see if the see issue is raised again at some point.
Author
Owner

I also suspects 2 minutes time shift making TOTP not work. wget command solves the issue.

I also suspects 2 minutes time shift making TOTP not work. `wget` command solves the issue.
Author
Owner

I have one hour shift again.

I have one hour shift again.
Author
Owner

Just rebooting my Debian 12 GNOME work laptop seems to lead to the issue.

While already have:

Screenshot from 2025-01-08 12-44-15

Just rebooting my Debian 12 GNOME work laptop seems to lead to the issue. While already have: ![Screenshot from 2025-01-08 12-44-15](/attachments/8950f092-f53c-4df4-9f61-a31237311fd0)
Author
Owner

I had to check my phone to ensure the time was correctly set (it was).

I had to check my phone to ensure the time was correctly set (it was).
Author
Owner

Does not seem related to secure boot as seems to have the issue on both states, related to Benjamin-Loison/cinnamon/issues/178 and Benjamin-Loison/obs-studio/issues/24.

Let us verify if Ubuntu and Windows also face the issue, let us update them as I do not regularly use them.
Have to reboot them to be accurate I would say.
Unlocking session may help. Waiting Internet access may be appropriate.

No issue on Ubuntu.
Face the same issue on Windows but may have BitLocker recovery bias, as have disabled secure boot I guess.

Maybe will have to dig BIOS.

Should try to firmware update from Debian or Ubuntu.

Does not seem related to secure boot as seems to have the issue on both states, related to [Benjamin-Loison/cinnamon/issues/178](https://github.com/Benjamin-Loison/cinnamon/issues/178) and [Benjamin-Loison/obs-studio/issues/24](https://github.com/Benjamin-Loison/obs-studio/issues/24). Let us verify if Ubuntu and Windows also face the issue, let us update them as I do not regularly use them. Have to reboot them to be accurate I would say. Unlocking session may help. Waiting Internet access may be appropriate. No issue on Ubuntu. Face the same issue on Windows but may have *BitLocker recovery* bias, as have disabled secure boot I guess. Maybe will have to dig BIOS. Should try to firmware update from Debian or Ubuntu.
Author
Owner

To be on time for work it is a very important issue.

To be on time for work it is a very important issue.
Author
Owner
fwupdmgr update
Output:
Devices with no available firmware updates: 
 • HP 5MP Camera
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI dbx
 • WD PC SN810 SDCPNRY-1T00-1406
Devices with the latest available firmware version:
 • System Firmware

on Debian 12 GNOME.

sudo does not help.

```bash fwupdmgr update ``` <details> <summary>Output:</summary> ``` Devices with no available firmware updates: • HP 5MP Camera • UEFI Device Firmware • UEFI Device Firmware • UEFI Device Firmware • UEFI dbx • WD PC SN810 SDCPNRY-1T00-1406 Devices with the latest available firmware version: • System Firmware ``` </details> on Debian 12 GNOME. `sudo` does not help.
Author
Owner
https://duckduckgo.com/?t=ftsa&q=CET+time&ia=web https://time.is/UTC+1 both above state 14:21. ![Screenshot from 2025-01-22 13-21-03.png](/attachments/64479133-1faf-4c83-be75-0b924d05994e)
Author
Owner

Screenshot from 2025-01-22 13-22-45.png

may be a workaround.

Well can set it along automatic time zone, let us restart to check.

Screenshot from 2025-01-22 14-23-26.png

![Screenshot from 2025-01-22 13-22-45.png](/attachments/d08d5502-2450-495b-b879-3715cbd9259e) may be a workaround. Well can set it along automatic time zone, let us restart to check. ![Screenshot from 2025-01-22 14-23-26.png](/attachments/6bc79b04-64a1-4c6b-b086-e8cf5f93fc04)
Author
Owner

I still have correct time (14:25) after reboot.

I still have correct time (14:25) after reboot.
Author
Owner

It ended up at some point (possibly with reboots) no more being at the right time again.

It ended up at some point (possibly with reboots) no more being at the right time again.
Author
Owner

DuckDuckGo search *Debian incorrect time while correct time zone *.

DuckDuckGo search *Debian incorrect time while correct time zone *.
Author
Owner
sudo dpkg-reconfigure tzdata
Output:

Screenshot from 2025-01-23 15-51-29.png

Screenshot from 2025-01-23 15-51-38.png

Current default time zone: 'Europe/Paris'
Local time is now:      Thu 23 Jan 15:52:04 CET 2025.
Universal Time is now:  Thu Jan 23 14:52:04 UTC 2025.

same output (including prompts) if execute again.

```bash sudo dpkg-reconfigure tzdata ``` <details> <summary>Output:</summary> ![Screenshot from 2025-01-23 15-51-29.png](/attachments/fc57f91a-9ac3-48d3-9f53-87ae5d6154de) ![Screenshot from 2025-01-23 15-51-38.png](/attachments/b1e49d03-610b-483f-8f49-a70dc663f780) ``` Current default time zone: 'Europe/Paris' Local time is now: Thu 23 Jan 15:52:04 CET 2025. Universal Time is now: Thu Jan 23 14:52:04 UTC 2025. ``` </details> same output (including prompts) if execute again.
Author
Owner
ntpdate pool.ntp.org
Output:
Command 'ntpdate' not found, but can be installed with:
sudo apt install ntpsec-ntpdate

Source: the Unix Stack Exchange answer 273113

sudo apt install -y ntpsec-ntpdate
Output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ntpsec-ntpdig python3-ntp
The following NEW packages will be installed:
  ntpsec-ntpdate ntpsec-ntpdig python3-ntp
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 150 kB of archives.
After this operation, 536 kB of additional disk space will be used.
Get:1 http://ftp.fr.debian.org/debian bookworm/main amd64 python3-ntp amd64 1.2.2+dfsg1-1+deb12u1 [88.9 kB]
Get:2 http://ftp.fr.debian.org/debian bookworm/main amd64 ntpsec-ntpdig amd64 1.2.2+dfsg1-1+deb12u1 [31.9 kB]
Get:3 http://ftp.fr.debian.org/debian bookworm/main amd64 ntpsec-ntpdate amd64 1.2.2+dfsg1-1+deb12u1 [29.0 kB]
Fetched 150 kB in 0s (361 kB/s)            
Selecting previously unselected package python3-ntp.
(Reading database ... 392043 files and directories currently installed.)
Preparing to unpack .../python3-ntp_1.2.2+dfsg1-1+deb12u1_amd64.deb ...
Unpacking python3-ntp (1.2.2+dfsg1-1+deb12u1) ...
Selecting previously unselected package ntpsec-ntpdig.
Preparing to unpack .../ntpsec-ntpdig_1.2.2+dfsg1-1+deb12u1_amd64.deb ...
Unpacking ntpsec-ntpdig (1.2.2+dfsg1-1+deb12u1) ...
Selecting previously unselected package ntpsec-ntpdate.
Preparing to unpack .../ntpsec-ntpdate_1.2.2+dfsg1-1+deb12u1_amd64.deb ...
Unpacking ntpsec-ntpdate (1.2.2+dfsg1-1+deb12u1) ...
Setting up python3-ntp (1.2.2+dfsg1-1+deb12u1) ...
Setting up ntpsec-ntpdig (1.2.2+dfsg1-1+deb12u1) ...
Setting up ntpsec-ntpdate (1.2.2+dfsg1-1+deb12u1) ...
Processing triggers for man-db (2.11.2-2) ...
ntpdate pool.ntp.org
2025-01-23 14:54:07.125559 (+0100) -3580.351680 +/- 0.016534 pool.ntp.org 82.64.45.50 s1 no-leap
CLOCK: step_systime: Operation not permitted
sudo ntpdate pool.ntp.org
2025-01-23 14:54:10.994883 (+0100) -3580.344012 +/- 0.022797 pool.ntp.org 82.64.45.50 s1 no-leap
CLOCK: time stepped by -3580.344012

corrects the time.
Let us verify that it holds a reboot.

Maybe no more having battery is involved.

```bash ntpdate pool.ntp.org ``` <details> <summary>Output:</summary> ``` Command 'ntpdate' not found, but can be installed with: sudo apt install ntpsec-ntpdate ``` </details> Source: [the Unix Stack Exchange answer 273113](https://unix.stackexchange.com/a/273113) ```bash sudo apt install -y ntpsec-ntpdate ``` <details> <summary>Output:</summary> ``` Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: ntpsec-ntpdig python3-ntp The following NEW packages will be installed: ntpsec-ntpdate ntpsec-ntpdig python3-ntp 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 150 kB of archives. After this operation, 536 kB of additional disk space will be used. Get:1 http://ftp.fr.debian.org/debian bookworm/main amd64 python3-ntp amd64 1.2.2+dfsg1-1+deb12u1 [88.9 kB] Get:2 http://ftp.fr.debian.org/debian bookworm/main amd64 ntpsec-ntpdig amd64 1.2.2+dfsg1-1+deb12u1 [31.9 kB] Get:3 http://ftp.fr.debian.org/debian bookworm/main amd64 ntpsec-ntpdate amd64 1.2.2+dfsg1-1+deb12u1 [29.0 kB] Fetched 150 kB in 0s (361 kB/s) Selecting previously unselected package python3-ntp. (Reading database ... 392043 files and directories currently installed.) Preparing to unpack .../python3-ntp_1.2.2+dfsg1-1+deb12u1_amd64.deb ... Unpacking python3-ntp (1.2.2+dfsg1-1+deb12u1) ... Selecting previously unselected package ntpsec-ntpdig. Preparing to unpack .../ntpsec-ntpdig_1.2.2+dfsg1-1+deb12u1_amd64.deb ... Unpacking ntpsec-ntpdig (1.2.2+dfsg1-1+deb12u1) ... Selecting previously unselected package ntpsec-ntpdate. Preparing to unpack .../ntpsec-ntpdate_1.2.2+dfsg1-1+deb12u1_amd64.deb ... Unpacking ntpsec-ntpdate (1.2.2+dfsg1-1+deb12u1) ... Setting up python3-ntp (1.2.2+dfsg1-1+deb12u1) ... Setting up ntpsec-ntpdig (1.2.2+dfsg1-1+deb12u1) ... Setting up ntpsec-ntpdate (1.2.2+dfsg1-1+deb12u1) ... Processing triggers for man-db (2.11.2-2) ... ``` </details> ```bash ntpdate pool.ntp.org ``` ``` 2025-01-23 14:54:07.125559 (+0100) -3580.351680 +/- 0.016534 pool.ntp.org 82.64.45.50 s1 no-leap CLOCK: step_systime: Operation not permitted ``` ```bash sudo ntpdate pool.ntp.org ``` ``` 2025-01-23 14:54:10.994883 (+0100) -3580.344012 +/- 0.022797 pool.ntp.org 82.64.45.50 s1 no-leap CLOCK: time stepped by -3580.344012 ``` corrects the time. Let us verify that it holds a reboot. Maybe no more having battery is involved.
Author
Owner

It holds a reboot.

It holds a reboot.
Author
Owner

I still have the issue after some time...

I still have the issue after some time...
Author
Owner

It's now a 2 hours time shift...

It's now a 2 hours time shift...
Author
Owner

To be able to investigate when the time shift occurs, let us add to crontab:

# [Benjamin_Loison/linux/issues/27](https://gitea.lemnoslife.com/Benjamin_Loison/linux/issues/27)
* * * * * date +%s >> date.txt

should then make an algorithm to detect significant shift.

To be able to investigate when the time shift occurs, let us add to `crontab`: ``` # [Benjamin_Loison/linux/issues/27](https://gitea.lemnoslife.com/Benjamin_Loison/linux/issues/27) * * * * * date +%s >> date.txt ``` should then make an algorithm to detect significant shift.
Author
Owner

How to be notified in real-time when the issue happens? Could leverage an always running server notifying if notice an offset of more than half an hour. This should not lead to false alarms as the time on resuming from suspension should be correct as tested but it happens sometimes to be incorrect.

How to be notified in real-time when the issue happens? Could leverage an always running server notifying if notice an offset of more than half an hour. This should not lead to false alarms as the time on resuming from suspension should be correct as tested but it happens sometimes to be incorrect.
Author
Owner

Could add ntpdate to visudo, done:

benjamin_loison ALL = (root) NOPASSWD: /usr/sbin/ntpdate pool.ntp.org
Could add `ntpdate` to `visudo`, done: ``` benjamin_loison ALL = (root) NOPASSWD: /usr/sbin/ntpdate pool.ntp.org ```
Author
Owner

Can somehow get time of motherboard, see Wikipedia: Real-time clock? Which should be stable without OS change.

Can somehow get time of motherboard, see [Wikipedia: Real-time clock](https://en.wikipedia.org/wiki/Real-time_clock)? Which should be stable without OS change.
Author
Owner

With Proton VPN at Amsterdam:

Screenshot from 2025-02-06 14-09-39.png

I received a notification that time has changed.

With Proton VPN at Amsterdam: ![Screenshot from 2025-02-06 14-09-39.png](/attachments/b74a6568-634f-4045-9d4e-e80296e74e24) I received a notification that time has changed.
Author
Owner

image.png

![image.png](/attachments/d253cb20-46d2-4059-9e26-d691ea34762c)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/linux#27
No description provided.