abu baniaz
Moderator
The real issue here is how it ever gets a future time set.
Wasn't that answered before? Two operations.
The real issue here is how it ever gets a future time set.

I think it sets one. Easy enough to check that, though.I think your presumption that ntpdate uses an absolute time is not correct.
It was the future fake_hwclock that was the issue, but I'd forgotten that you had a double advance.I'm assuming that in the case of the double start of ntpdate one is picking up the result of the other and applying it twice.
I now have an ntpdate-sync script which runs ntpdate in the background when called from enigma2, but in the foreground if called when an interface is brought up (i.e. METHOD is set).
The former is needed to ensure that the time is set before services start (the whole point of the original change) and the latter is needed as enigma2 runs it using Console.ePopen(), and the Vix spinner pops up if that doesn't complete in <5s(?), which it usually won't.
This is it:
View attachment 55805
I think it sets one. Easy enough to check that, though.
It was the future fake_hwclock that was the issue, but I'd forgotten that you had a double advance.
Perhaps ntp should be taking its own lock when it working....given that there is nothing else to stop it being run twice on any system. It shoudln't be relying on any external mutex mechanism.
I didn't realise that feature was there (to enable fake-hwclock to be set in the past). I'll enable it now!No. It has a check to ensure it isn't being run twice at the same time, but that is only done if the /usr/bin/lockfile-create exists, which it doesn't by default on OpenVix.
That's a deliberate design feature, although I forget why.
It's configurable by uncomment the line in /etc/default/fake-hwclock.
What happens if you login and run the script on the command line?@birdman - I installed your script change and shut the box down and pulled the power overnight. This morning I started up but ntpdate-sync is not updating my system time at all now. It appears to be running but it's not changing the system clock time which started from the fake-hwclock.data of 07.30 set last night.
Out of interest. What happens if the box isn't networked at all and is just being used as a stand alone broadcast receiver/PVR?
That's why I asked if you use oscam.Also, the fact that fake-hwclock.data does not get updated once it has a value into the future is another issue.
Because it "can't be".[Why doesn't fake-hwclock doesn't restore time if it's earlier than current time]
That's a deliberate design feature, although I forget why.
Indeed.The real issue here is how it ever gets a future time set.
Those statements are incorrect as, with the current script, the ntpdate-sync is run in the background. Hence £2 (and all other services) can actually start with the fake-hwclock, not the correct one as set by ntp.Later at boot it tries an NTP sync, which is perfectly ok to fail.
If it succeeds, the box now has the accurate time set, if it fails, it will continue with last shutdown time (or image build time) plus some seconds since fake-hwclock was restored.
At the end, E2 starts up and syncs time again, either using DVB or using NTP, depending on what's set.
No, it's not, ...Those statements are incorrect
... although this is also not incorrect.as, with the current script, the ntpdate-sync is run in the background. Hence £2 (and all other services) can actually start with the fake-hwclock, not the correct one as set by ntp.
That would indeed most probably solve the "two instances at once" issue at boot time, but it'sHence my change to the ntpdate-sync script to run ntpdate in the foreground when an interface is brought up. This also prevents the two initial ntpdates from running together, as the first one (interface up) is run in the foreground so completes before E2 starts wherupon it may run another (which will run in the background to avoid the Vix spinner showing).
No, it's not, ...
... although this is also not incorrect.
The two explanations are completely compatible ...
If the initial ntpdate-sync fails (or takes long), E2 will start with the fake-hwclock time, just like you said.
That's absolutely no problem at all though, as it will later do some own time sync (Either DVB or NTP) anyways and previously E2 sometimes even started on 1970-01-01 and had no problem with it.
The only problem is that currently two sync can happen at the very same time.
That would indeed most probably solve the "two instances at once" issue at boot time, but it's
- only a quirky workaround
- slowing down boot on non-networked or slowly connecting boxes extremely
- will not prevent two instances of ntpdate-sync running at the same time under other circumstances (e.g. one ntpdate-sync run by cron and the other by E2)
There is an easy and clean solution:
Adding the lockfile-progs that are already anchored in ntpdate-sync will prevent concurrent runs of ntpdate-sync under all conditions and ntpdate-sync can stay backgrounded.
That needs to be done by the image makers...... and how is that done ...or have I just missed it in all these conversations?
That's why I asked if you use oscam.
oscam's "CLOCKFIX" would do exactly that: It prevents time adjustments to "past" times. CLOCKFIX = Forward ever, backward never!
Afaik, the oscams from ViX feed are now built without the CLOCKFIX (Which is actually a CLOCKBREAK), but most oscams from other sources are built with CLOCKBREAK.
What happens if you login and run the script on the command line?
Odd that it works for for me. I've just booted up my box, which started with a time of 02:00:43 (last shutdown) but by the time enigma2 started its log was Enigma2_debug_2018-01-18_16-46-12.log - i.e. the time had been corrected using ntp.
I'm actually using a version with some debug code in it. This is it:
View attachment 55806
It will log when it runs to syslog (so /var/log/messages - except the first runs, which are before syslog starts) and also log the trace of its runs to /var/tmp/gml.log (which starts anew on each reboot).
The latter in particular should show what is (not) happening.
I presume that you've made the script executable (otherwise it won't be run...)?
The box will always start with the last shutdown (or image build time) during early boot.
Later at boot it tries an NTP sync, which is perfectly ok to fail.
If it succeeds, the box now has the accurate time set, if it fails, it will continue with last shutdown time (or image build time) plus some seconds since fake-hwclock was restored.
At the end, E2 starts up and syncs time again, either using DVB or using NTP, depending on what's set.
The problem is, that ntpdate-sync runs without locks against multiple concurrent runs at once which can lead to double adjustments.
I didn't realise that feature was there (to enable fake-hwclock to be set in the past). I'll enable it now!
So I see from your reply that the check for double running of ntpdate-sync does not work on Vix because the lockfile creation mechanism doesn't work? That would explain my issues with double clock adjustment.
< 1833.285> [NetworkTime] Updating
< 1833.286> [Console] command: /usr/bin/ntpdate-sync
< 1833.286> [eConsoleAppContainer] Starting /bin/sh
< 1833.303> [Console] finished: /usr/bin/ntpdate-sync
< 1833.303> [NetworkTime] setting E2 time: 1516315624.3