How do I get cron to email me ONLY when files have been modified?
If you are on Linux with a local file system (e.g. ext4(5) or BTRFS), consider using inotify(7) facilities and then install incrond
(on Debian or Ubuntu: the incron
package) and use incrontab(5).
Be aware that incron
and inotify
don't work on remote file systems such as NFS or SMB/CIFS or on pseudofile systems like proc(5).
If you cannot use incron
you'll need to use find(1) and perhaps stat(1) in your shell script periodically called by cron
BTW, some files (e.g. those under /var/run/
, see hier(7) for more) are very often modified. And so are the data files handled by RDBMS such as PostGreSQL
Regarding AIDE, be sure to read its documentation. Since it is open source and even free software, consider studying then improving its code (e.g. to use inotify
).