[systemd-devel] Journal log rotation notification

Mantas Mikulėnas grawity at gmail.com
Fri Aug 14 04:56:50 PDT 2015


On Fri, Aug 14, 2015 at 2:20 PM, giulix <giulio.martinat at gmail.com> wrote:

> Hello,
>
> I have a process that reads from the journald log file. It gets a
> notification from inotify that something's changed, opens the journal,
> skims through it for messages it's interested in, does its stuff and closes
> the journal file (
> http://www.giulix.it/content/extracting-data-systemd-journal-programmatically
> ).
> When the journal log file is rotated, the process stops to do its job. It
> is, of course, because it never realizes the file it's waiting on for
> notifications via inotify has changed.
> I have uselessly tried to implement some mechanism to have my process
> restarted when the journal file changes, but it seems that nothing is
> available from systemd or journald to notify a process that journald is
> switching to a new output file.
>

There is no need for a signal – inotify can inform you about renames as
well.

But, you shouldn't reimplement the entire logic yourself. (There's more to
it, like separate systemd or user journals....) *Instead, call
sd_journal_get_fd(3) and let libsystemd do the monitoring.*

-- 
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150814/2f3e2002/attachment.html>


More information about the systemd-devel mailing list