-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WeeWX starts before clock correct when using ntp #946
Comments
But, that won't work if systemd-timesyncd is in use, which is the default on an RPi. |
I think it will just quietly fail and due to the leading '-' continue anyway. It did on my machine when I mistyped the command at first! |
Most users are going to use the default, which works. If a user wants to use ntp, then some modifications should be expected. |
I just tried to add a note to https://github.com/weewx/weewx/wiki/Time-services/#ntp to reference this case, but seems I can't edit this. Or I have missed something obvious. |
You have to be logged into GitHub. Other than that, I don't think there are any requirements to edit anything in the wiki. |
OK I tried it again and it seems to have worked. Maybe last time I forgot to add a note about the change or similar, as the 'save' button went greyed out as if doing something but it never completed. |
I just installed a RTC. They are cheap and Chrony in place of NTP it will adjust the clock for you.
chrony – Comparison of NTP implementations (chrony-project.org) <https://chrony-project.org/comparison.html>
…-dk
Duane Kerzic
138 Old Kettle Court
Stroudsburg, PA 18360
18TVL748345
570.982.4381
KB3ZXE
Notice: The information contained in the e-mail message is intended only for the confidential use of the recipient(s) named above. This message is privileged and confidential. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, copying or use is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the original message.
This e-mail and any files transmitted with it are confidential and intended for the use of the individual or entity to which they are addressed. If you have received this e-mail in error please contact ***@***.***> Duane P. Kerzic
From: Paul Crawford ***@***.***>
Sent: Sunday, March 31, 2024 12:47 PM
To: weewx/weewx ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [weewx/weewx] WeeWX starts before clock correct when using ntp (Issue #946)
OK I tried it again and it seems to have worked. Maybe last time I forgot to add a note about the change or similar, as the 'save' button went greyed out as if doing something but it never completed.
—
Reply to this email directly, view it on GitHub <#946 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOLUVYKSXQN34RGEI3Q37O3Y3A4ZJAVCNFSM6AAAAABFQIHKU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYHAYTSNZUGI> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/AOLUVYJVY7VHYNG4YSX2ID3Y3A4ZJA5CNFSM6AAAAABFQIHKU6WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTY5VKR4.gif> Message ID: ***@***.*** ***@***.***> >
|
The NTP vs Chrony vs OpenNTPD debate is kind of irrelevant as none of them are properly detected by systemd's built-in time check. I don't know if chrony has an equivalent wait-for-sync command to the However it all comes back to the same point: if time matters before WeeWX is started, which is the case, you need to take extra steps to make sure it has been synchronised by whatever system you have chosen whenever it is not systemd's built-in choice. |
I think you missed the RTC (REAL TIME CLOCK). HiLetgo 5pcs DS3231 High Precision RTC Real Time Clock Module 3.3V/5V for Arduino Raspberry Pi: Amazon.com: Industrial <https://www.amazon.com/HiLetgo-DS3231-Precision-Arduino-Raspberry/dp/B01N1LZSK3/ref=sr_1_2?crid=1T6NRU49Y529M&dib=eyJ2IjoiMSJ9.i5MRxeSfNbDKjMFNUkHLWDS1AJmp4Sk1_BwXS7gax69c8abzJ1102-zG70aF6J-pwSPqJij5lfpCeFlezrHIZCFSfmczzndJmE7Zp4Jtvc7pYg3GExsE9P3hW7JoY_J8rTfNYMDJ8yK1CSg-uMbl8lnwLtgh0-e31JAZgmodatGCfQ1CqYOGTMmDeHTAAVvoWA7Jlkk1q28Zzh_CLHxlXldus9OTCh25mTJzHTl0GVg.0QVlMmGVm_20K6IqDIl8Oi6V--ZKyNacGTpFzsfYoqA&dib_tag=se&keywords=rtc+for+raspberry+pi&qid=1711939131&sprefix=rtc+for+%2Caps%2C91&sr=8-2> & Scientific
If you have a RTC your system has the time before WeeWX starts. Because it has the time when it boots. No need to wait for sync.
…-dk
From: Paul Crawford ***@***.***>
Sent: Sunday, March 31, 2024 4:52 PM
To: weewx/weewx ***@***.***>
Cc: Duane Kerzic ***@***.***>; Comment ***@***.***>
Subject: Re: [weewx/weewx] WeeWX starts before clock correct when using ntp (Issue #946)
The NTP vs Chrony vs OpenNTPD debate is kind of irrelevant as none of them are properly detected by systemd's built-in time check. I don't know if chrony has an equivalent wait-for-sync command to the ntp-wait that I used.
However it all comes back to the same point: if time matters before WeeWX is started, which is the case, you need to take extra steps to make sure it has been synchronised by whatever system you have chosen whenever it is not systemd's built-in choice.
—
Reply to this email directly, view it on GitHub <#946 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOLUVYNIIH2JWI3SJ44VWBLY3BZP3AVCNFSM6AAAAABFQIHKU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYHEYDCOBWHA> .
You are receiving this because you commented. <https://github.com/notifications/beacon/AOLUVYJQHULO7XJPRNWNBFTY3BZP3A5CNFSM6AAAAABFQIHKU6WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTY52K6Y.gif> Message ID: ***@***.*** ***@***.***> >
|
Doesn't the RPi5 come with a RTC? Pretty sure you just need to supply a battery. |
Yes the RPi5 come with a RTC. All you need is a battery holder and battery, Amazon.com: Treedix 2pcs RTC Battery Case Real Time Clock Holder Compatible with Raspberry Pi 5 : Electronics <https://www.amazon.com/Treedix-Battery-Holder-Compatible-Raspberry/dp/B0CWDFN51V/> .
I don’t know which version of RPi he has. I have a 4, it doesn’t come with a RTC. And I believe you can run WeeWx on a RPi2 and certainly on a 3, again no RTC.
…-dk
From: evilbunny2008 ***@***.***>
Sent: Sunday, March 31, 2024 11:53 PM
To: weewx/weewx ***@***.***>
Cc: Duane Kerzic ***@***.***>; Comment ***@***.***>
Subject: Re: [weewx/weewx] WeeWX starts before clock correct when using ntp (Issue #946)
Doesn't the RPi5 come with a RTC? Pretty sure you just need to supply a battery.
—
Reply to this email directly, view it on GitHub <#946 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOLUVYJVJLEXQ4FCMHQZZO3Y3DKZFAVCNFSM6AAAAABFQIHKU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRZGEYTENZZGA> .
You are receiving this because you commented. <https://github.com/notifications/beacon/AOLUVYLHADJUSJJFMZ2WC23Y3DKZFA5CNFSM6AAAAABFQIHKU6WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTY6HG5M.gif> Message ID: ***@***.*** ***@***.***> >
|
Thanks for the RTC suggestions, it is a Pi 3B I am using. I have one which has a GPS board with RTC though the RTC side never seemed to work. However, this is missing the point! The WeeWX package should be waiting for time-sync before starting so that ought to be a secondary consideration (after all the RTC could be wrong) and if you are using systemd's own method that works. My point was if you use NTP or something else you need to modify the weewx.service file to put in a synchronisation check that actually works with your choice of time-sync method. Mine was NTP hence the use of |
Now that the WeeWX code runs as a systemd service there is an assumption that it will get the correct time using the 'Requires=time-sync.target' statement. However, that is not necessarily true if ntp is in use instead and that is very apparent on devices like a Raspberry PI that lacks a real-time clock to set time on boot.
A fix I found it to edit the systemd service /lib/systemd/system/weewx.service and adding ntp-wait to the pre-start list, with '-' preceding it so failure is ignored (which might be the case if no network at all, or ntp removed). So you should then have something like:
The text was updated successfully, but these errors were encountered: