Как обеспечить истечение срока действия журнала с помощью journald?

sed -E '/^[[:blank:]]*<description><!\[CDATA\[/s/([!?.])[^!?.<]*<a/\1 <a/' file

Это будет искать все строки, начинающиеся с точной строки <description><![CDATA[(, возможно, перед которой стоят пробелы или табуляция ). В этих строках будет произведена замена.

Замена соответствует ограничителю предложения ([!?.]), за которым следует любое количество символов, которые не являются не ограничителями предложения или <, и строкой <a. Это будет заменено первым разделителем предложения, пробелом и строкой <a.

2
11.02.2020, 07:02
1 ответ

Вы должны уметь использовать --vacuum-time. Что-то вроде следующего заменит текущие активные файлы журнала в архив, а затем обрежет все журналы, чтобы в одном журнале оставалось только 10 дней.

journalctl --rotate --vacuum-time=10days    

Прямо из справочной страницы:

--vacuum-size=, --vacuum-time= and --vacuum-files= may be combined
       in a single invocation to enforce any combination of a size, a time
       and a number of files limit on the archived journal files.
       Specifying any of these three parameters as zero is equivalent to
       not enforcing the specific limit, and is thus redundant.

       These three switches may also be combined with --rotate into one
       command. If so, all active files are rotated first, and the
       requested vacuuming operation is executed right after. The rotation
       has the effect that all currently active files are archived (and
       potentially new, empty journal files opened as replacement), and
       hence the vacuuming operation has the greatest effect as it can
       take all log data written so far into account.
1
28.04.2021, 23:23

Теги

Похожие вопросы