Local delivery to mbox / inode issue

I am using incrond to monitor an mbox file (in /var/mail) for changes, but
it is failing to trigger when postfix adds an incoming mail to the file.
(It triggers fine however if I touch the file.)

I may be barking up the wrong tree but I wonder if this is because instead
of merely appending to the existing mbox file, postfix/local rewrites the
file so that its inode changes (which I know breaks incrond's ability to
monitor a file). If so, is there a way to get postfix to append to the file
without changing the inode, and if so what are the disadvantages?

I have postfix 3.3.0, local has default settings, and /var/mail is on
filesystem ext4 (options rw,relatime,data=ordered) under Ubuntu 18.04.1
(GNU/Linux 4.15).


Re: Local delivery to mbox / inode issue

By Wietse Venema at 12/06/2018 - 11:08

Dominic Raferd:
Possible causes:

- Your file system does not set the file mtime when Postfix appends
to the file. Fix: don't disable mtime updates for append operations.

- There is a clock drift problem where the host with Postfix has
different time than the host with the file system. Fix: run NTP on
both hosts.

Have you verified that the inode number changes?

Postfix opens an mbox file with O_APPEND mode which is standardized
by the POSIX API. If that causes the file inode number to change,
then you need to use a different file system.