Score:0

Would like local time to be automatically updated

us flag

I am using Ubuntu 20.04 server edition on a RPi 4. I have seen tutorials and posts on how to set the local time manually. However, I would like to set the device to automatically update the local time zone to reflect any changes using NTP. For instance, if I have the device running in Eastern time zone and then take it with me to the Pacific time zone or even to Europe, I want it to automatically update this info and display it with the "date" command as long as it has a connection to the outside world. I appreciate the guidance.

Seeing the following when running timedatectl

ubuntu@ubuntu:~$ timedatectl

Local time: Mon 2021-11-29 15:28:14 UTC

Universal time: Mon 2021-11-29 15:28:14 UTC

RTC time: n/a

Time zone: Etc/UTC (UTC, +0000)

System clock synchronized: yes

NTP service: active

RTC in local TZ: no

date command only shows UTC

waltinator avatar
it flag
How will the PI detect that it's been moved, or, even, which timezone it's in?
noobuntu avatar
us flag
Was hoping it would be able to sync up with either the main gateway or via some close by NTP server. What are your thoughts?
waltinator avatar
it flag
NTP, and almost all internet time is in UTC (Windows keeps its time in Local Time Zone). Conversion to your local time zone is performed on your local system. That's why I asked the questions you didn't answer.
in flag
Is RTC time usually "n/a" for Raspberry Pis?
noobuntu avatar
us flag
Hi @waltinator. Not meaning to avoid your question. I may just not understand what it is you are asking. To add to my previous attempt in hopes of providing an answer, if I can figure out a method for the device to "sense" it's surroundings, I would probably create a script that runs upon boot up. Is this what you are asking? also, you mentioned Windows doing this with Local time. This is the behavior I am trying to create. I believe even my Nintendo Switch was able to tell what time zone it was in when I first set it up, but it's been a while. If not possible, please let me know.
noobuntu avatar
us flag
@ryanttb That's a valid question. I'm not sure what the typical behavior is, but will let you know today once I find out. I have not yet set a local time zone, which may the the issue here. Again, not sure and will need to find out. Thanks
noobuntu avatar
us flag
@ryanttb I found this: "The Raspberry Pi is designed to be an ultra-low cost computer, so a lot of things we are used to on a computer have been left out. For example, your laptop and computer have a little coin-battery-powered 'Real Time Clock' (RTC) module, which keeps time even when the power is off, or the battery removed. To keep costs low and the size small, an RTC is not included with the Raspberry Pi. Instead, the Pi is intended to be connected to the Internet via Ethernet or WiFi, updating the time automatically from the global ntp (nework time protocol) servers" at Adafruit.com
waltinator avatar
it flag
Does this answer your question? [How to change time-zone settings from the command line](https://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line)
waltinator avatar
it flag
You can change the timezone manually. See https://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line
noobuntu avatar
us flag
@waltinator No, but thanks. Manually isn't what I'm wanting. I don't know how to proceed on this. Would be nice to have an application I can include in the build, but not sure if here is such a thing. At this moment, I'm going to say it's probably not possible. However, I will keep researching. Thanks for the input.
waltinator avatar
it flag
Unless you add a GPS dongle to find out where you are, OR compare the first few hops of `traceroute 8.8.8.8`, OR figure out a computer-detectable difference between the environments your computer lacks the information to guess a timezone.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.