date and time not updating correctly

March 23, 2024, 13:06

dietherdave

hello. does anyone know why my raspberry pi does not update date and time? localisation is already correct but date and time is not correct. im running bookworm im from philippines manila asia. it is set correctly but still wrong. i needed to run this command every boot to just get the correct date and time sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

k9t33n

and if you want it to be the same immediately from boot and without WiFi you can use an [RTC](https://en.m.wikipedia.org/wiki/Real-time_clock )

oops.se

What Raspberry Pi model is it? Pi 5 have a built in RTC Other models need a external RTC clock module, cost a couple of dollars But as <@1071178789939331253> say use NTP and to enhance the NTP you can configure a NTP source aka "NTP pool" that is closer to your home by editing ntp.conf

oops.se

To find a NTP server pool closer to your home, check https://www.ntppool.org/en/

dietherdave

Using my rpi before, after update and setting the localisation options, it just updates the date and time correctly of the OS without further setups.

k9t33n

interesting. i don not know but maybe the things i mentioned could still help

starsalt

Try using this: ## sudo apt install htpdate It takes time from headers instead of from an ntp pool.

starsalt

I ran into that problem around last month i think? Idk what's causing it but this one worked for me

starsalt


oops.se

Strange picture of text, as NTP is addressing just those issues and has been an major component in all kind of devices from small IoT devices, networking equipment and server since 1985. And to say "Better" is just BS.

oops.se

Check out https://discord.com/channels/818384379197784084/1047463526043746304 to learn how to format text correctly.

starsalt

Tbh idk what caused it but ntp didn't work for me too just like OP's issue. The thing is i think it's with regards to the ISP/maybe the location, cause i could never get ntp to work on my home wifi but when i used mobile data somehow it updated properly. - i tried rebooting and stuff connected to wifi but to no avail it only syncs on mobile data (though maybe i just did smth wrong) I'm from the same place as OP so idk if that's it?

starsalt

Also, for context: the "Better" on the pic is not referring to ntp btw, there was a quickfix script that he made with regards to setting up time to sync without ntp and htpdate (my bad though for cropping wrong), reason being they couldn't get ntp to work too maybe?

k9t33n

You can set your location manually with ntp

k9t33n

But the same location does raise a valid point

starsalt

Yes, it might be the isp thing? Something preventing ntp.

k9t33n

So the abbreviation for the Philippines is PHT

k9t33n

so you would pass that as an argument when running NTP. I'll find out how to do that in a bit

k9t33n

Or if htpdate is working for you, you may also try that.

k9t33n

I'm going to eat now so bye

starsalt

Yus that's what im using rn on my pizero hehe though i will try to fix it again when i update my pi4 soon

oops.se

Many ISP provides NTP services as well and some even provide that service from the home router/firewall.

oops.se

And to investigate this issue it's pretty easy to check if that port is blocked by the ISP instead of guessing and assuming...

starsalt

yus i'll keep that in mind tyvm hehe i do plan to fix it

dietherdave

I think this issue is only happening in the philippines. Any rpi I use has this same issue.