.. SPDX-License-Identifier: Apache-2.0

.. _param-imfile-reopenontruncate:
.. _imfile.parameter.input.reopenontruncate:
.. _imfile.parameter.reopenontruncate:

reopenOnTruncate
================

.. index::
   single: imfile; reopenOnTruncate
   single: reopenOnTruncate

.. summary-start

Experimental: reopen the input file if it was truncated without changing its inode.

.. summary-end

This parameter applies to :doc:`../../configuration/modules/imfile`.

:Name: reopenOnTruncate
:Scope: input
:Type: boolean
:Default: off
:Required?: no
:Introduced: at least 8.x, possibly earlier

Description
-----------
When activated, tells rsyslog to reopen the input file if it was truncated
(the inode is unchanged but the file size on disk is smaller than the
current offset in memory). The offset restored from the state file is
included. After a restart, a saved offset past the end of the file makes
reading start again at byte 0, so the lines that remain are read again.
This feature is experimental. The default is off.

Input usage
-----------
.. _param-imfile-input-reopenontruncate:
.. _imfile.parameter.input.reopenontruncate-usage:

.. code-block:: rsyslog

   input(type="imfile"
         File="/var/log/example.log"
         Tag="example"
         reopenOnTruncate="on")

Notes
-----
- Legacy documentation used the term ``binary`` for the type. It is treated as boolean.
- This parameter is **experimental** and may change.

See also
--------
See also :doc:`../../configuration/modules/imfile`.
