<div dir="ltr">Hi All,<br><br>I was trying to write a program that tailed the journal, but found that sd_journal_seek_tail() didn't work as expected.<br>That is: that it would seek to the last/most recent thing in the journal, and I could tail things from there.<div><br>I whipped up a quick demonstration program, that shows that messages I 'next' through, are before the 'cutoff':</div><div><br><div><span class="" style="white-space:pre">   </span>#include <stdio.h></div><div><span class="" style="white-space:pre">   </span>#include <assert.h></div><div><span class="" style="white-space:pre">  </span>#include "systemd/sd-journal.h"</div><div><br></div><div><span class="" style="white-space:pre"> </span>int main() {</div><div><span class="" style="white-space:pre">               </span>sd_journal* j;</div><div><span class="" style="white-space:pre">             </span>assert(sd_journal_open(&j, 0)==0);</div><div><span class="" style="white-space:pre">             </span>uint64_t from, to;</div><div><span class="" style="white-space:pre">         </span>assert(sd_journal_get_cutoff_realtime_usec(j, &from, &to)==1);</div><div><span class="" style="white-space:pre">             </span>printf("CUTOFF = %llu\n", to);</div><div><br></div><div><span class="" style="white-space:pre">          </span>printf("TAIL = %d\n", sd_journal_seek_tail(j));</div><div><br></div><div><span class="" style="white-space:pre">         </span>for (int i=0; i<10; i++) {</div><div><span class="" style="white-space:pre">                      </span>printf("NEXT = %lld\n", sd_journal_next(j));</div><div><span class="" style="white-space:pre">                     </span>assert(sd_journal_get_realtime_usec(j, &from)==0);</div><div><span class="" style="white-space:pre">                     </span>printf("FOUND from %llu\n", from);</div><div><span class="" style="white-space:pre">               </span>}</div><div><span class="" style="white-space:pre">          </span>return 0;</div><div><span class="" style="white-space:pre">  </span>}</div><div><br></div><div>Compiled with: gcc -std=c99 tail_logs.c -l systemd</div><div><br></div><div>Example output:</div><div><br></div><div><div><span class="" style="white-space:pre">    </span>CUTOFF = 1413177397982789</div><div><span class="" style="white-space:pre">  </span>TAIL = 0</div><div><span class="" style="white-space:pre">   </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400437372012374</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753925868</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926192</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926257</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926289</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926309</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926330</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926353</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926373</div><div><span class="" style="white-space:pre">        </span>NEXT = 1</div><div><span class="" style="white-space:pre">   </span>FOUND from 1400438753926395</div></div></div><div><br></div><div><br></div><div>Is this behaviour expected? I'm using systemd 216.</div><div><br></div><div>Regards,</div><div>Daurn.</div><div><br></div></div>