I'm sure I do not completely understand your question:
You seem to be asking how to use ntpd
to update your el cheapo RTC.
You have seemingly found how to update your RTC from the RPi's system time, and I think @Milliways comment has also addressed that point.
You haven't stated your accuracy requirements, and it seems that you may not be entirely clear on whether or not the RPi's default SNTP is capable of meeting your requirement.
And finally, perhaps in further confusion, it has been opined that running ntpd
has been made awkward by systemd-timesyncd
.
All that said, the following is offered to help sort some of this:
1. NTP vs SNTP on Raspberry Pi
A SE Q&A from 2018 covered some of the details of how NTP (and ntpd
) came to be dropped from the RPi, and replaced with SNTP. It also offers a few words on the timekeeping function in general on RPi. AFAIK, the two answers there are still correct. Reading through this Q&A may advise your course of action. This document provides a summary of the diffs between NTP and SNTP
2. Accuracy Expectations
Some measurements on the RPi's internal clock, and included in this Q&A suggest that your RTC - despite its el cheapo rating - will provide far better accuracy than the RPi system clock! A referenced article supports a claimed accuracy (using NTP) of "less than 100msec", but pay attention to the caveats.
This suggests that even with some network instability/outages your RTC should be able to maintain your RPi's system clock to considerably less than 1 second error. If you need reasonable accuracy, and you suffer network outages, I'd say your RTC was a good investment of £4. If you need better than that, consider investing in a GPS - or a better RTC.
3. Offing systemd-timesyncd
As noted in # 1 above, RPi's default timekeeping service is SNTP via systemd-timesyncd
. However, you can replace the default timekeeping to ntpd
, chronyd
, openntpd
- or any other timekeeping client you choose - without interference or hassle from systemd-timesyncd
.
In fact, you don't even need to notify systemd-timesyncd
- simply install ntpd
, chronyd
or openntpd
, and systemd-timesyncd
will abide by your choice. In other words, if systemd-timesyncd
detects one of these services running, it will stand down - it automatically defers to your choice. I'm still astonished at the politeness of this... if all software were this polite!
You may verify this for yourself as follows:
$ systemctl cat systemd-timesyncd | less
Note the last several lines of the output listing:
# /lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf
[Unit]
# don't run timesyncd if we have another NTP daemon installed
ConditionFileIsExecutable=!/usr/sbin/ntpd
ConditionFileIsExecutable=!/usr/sbin/openntpd
ConditionFileIsExecutable=!/usr/sbin/chronyd
ConditionFileIsExecutable=!/usr/sbin/VBoxService
4. Manual Updates to System Time
You asked:
how can I access/call NTP time from the command line?
AFAIK, this is not possible, but the (now deprecated) ntpdate
or the ntpsec-ntpdate
utilities may accomplish your objective by setting the system time from an NTP server. They may be installed on RPi in the usual way using apt
. It's not clear to me why you want to do this manually - unless you have no Internet connection at all, but if you do, perhaps this will work.
If you're into manually updating your system clock - or have no Internet connection, this may interest you:
$ date -s 'YYYY-MM-DD HH:MM:SS'
see man date
if you need the details
In Conclusion
Hope this helps - let us know if you have further questions.
systemd
timekeeping function, it seems at odds with your comment. But perhaps things have changed? REF – Seamus Jan 04 '21 at 00:30