<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Well, systemd itself uses Linux timerfd to receive "clock changed" events. See time_change_fd() in src/basic/time-util.c, and the large comment in clock_state_update() in src/time-wait-sync/time-wait-sync.c in systemd's source tree.<br><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 15, 2018 at 4:15 PM D.S. Ljungmark <<a href="mailto:ljungmark@modio.se">ljungmark@modio.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">That could work, but then it’s still needing a signal to figure it out in order to get it right. Thanks. I’ll see about implementing that. </div></div><div><br><div class="gmail_quote"><div dir="ltr">On Sat, 15 Sep 2018 at 14:28, Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Sep 15, 2018 at 3:02 PM D.S. Ljungmark <<a href="mailto:ljungmark@modio.se" target="_blank">ljungmark@modio.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>I’ve got a follow up here. We want code to run both before and after time is synchronized the first time. But we -also- need to know how big the first time jump is. <br></div><div><div class="gmail_quote"><div dir="auto">It’s lokel to be in the matter of weeks or months in our application, and we’d want to know how much it was lagging. </div><div dir="auto">We start logging measurements before things are connected, and tag them as unknown, later when we get an application sync on time we can recalculate to proper dates,( provided we weren’t losing power for many times before we get a network sync)</div></div></div></blockquote><div><br></div><div>AFAIK you could look at the difference between real time and CLOCK_BOOTTIME (or MONOTONIC). Whenever you notice the clock jumping, compare the new difference with the previously seen one, and you'll know how much to offset the old records by. That doesn't depend on any external software and works just as well with timesyncd as it does with ntpdate or manual adjustments.</div><div><br></div><div>(For example, every journald entry includes the real-time *and* monotonic timestamps.)</div></div></div><div dir="ltr"><div><br></div>-- <br><div dir="ltr" class="gmail-m_9061388999770190627m_6313186017809911005gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div></div></div></div>