ka3j
Posts: 3
Joined: Sun May 31, 2020 5:00 am

Best Way to Manually Set the Clock

Tue Jul 07, 2020 3:10 am

I need to set my clock within 1 second of "real" time as posted on time.is and similar sources. This is required by my digital radio application. The built-in NTP synchronization (Pi 3A+ with current OS) will usually provide this but not always. So when it doesn't, I would like to manually set the time rather than using an RTC or GPS.

Will the following steps work without causing problems or is there a better way?

1. It appears necessary to first stop the synchronization that normally occurs. A suitable command for doing this appears to be:
sudo systemctl disable systemd-timesyncd.service
then reboot

2. Can the time then be set using any of the following commands?
sudo date -s 2014-12-25 12:34:56
sudo timedatectl set-time 2020-10-02 21:59:33
sudo timedatectl set-time '12:00:00'

Please advise whether there are any syntax errors in the above commands.

3. Hopefully the clock will maintain the necessary accuracy over a relatively short period - say 1 hour. After that I would want to return the clock to its original state. Will the following command achieve this?
sudo systemctl enable systemd-timesyncd.service
then reboot

Thanks for your help!

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Best Way to Manually Set the Clock

Tue Jul 07, 2020 8:12 am

sudo apt install ntp
sudo systemctl disable-timesyncd
sudo reboot
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Beginners”