Monitor directories for new files.
Find a file
Courtney Rosenthal b7bd210b3c
All checks were successful
/ test (push) Successful in 20s
added test action workflow
2025-10-20 07:34:33 -07:00
.forgejo/workflows added test action workflow 2025-10-20 07:34:33 -07:00
.gitignore ignore __pycache__ 2025-10-13 14:01:57 -07:00
created-file-monitor.py Renamed file-monitor to created-file-monitor. 2025-10-13 15:23:22 -07:00
LICENSE added LICENSE 2025-10-13 11:56:02 -07:00
Makefile Renamed file-monitor to created-file-monitor. 2025-10-13 15:23:22 -07:00
README.md Moved testing info into README 2025-10-15 10:26:05 -07:00
requirements.txt Added requirements.txt. 2025-10-14 12:48:40 -07:00
test_created_file_monitor.py Renamed file-monitor to created-file-monitor. 2025-10-13 15:23:22 -07:00

created-file-monitor

created-file-monitor - Monitor directories for new files.

created-file-monitor scans one or more directories and reports files present. It can optionally maintain state across runs and report only newly created files.

The original use case was a periodic process, run via cron, to scan /var/spool/nullmailer/failed for errors from the nullmailer system.

Usage

created-file-monitor [--state|-S FILE] DIRECTORY ...

Options

  • --state FILE or -S FILE -- State file for tracking previously seen files across runs
  • DIRECTORY -- One or more directories to monitor

Examples

created-file-monitor --state /var/cache/nullmailer-failed.dat /var/spool/nullmailer/failed

created-file-monitor --state ${XDG_STATE_HOME:-$HOME/.local/state}/created-file-monitor.dat /path/to/dir1 /path/to/dir2 ...

Requirements

  • Python 3.x
  • No external dependencies (uses only standard library)

Testing

A comprehensive test suite is provided using pytest. To run the tests:

pip install pytest
pytest test_created_file_monitor.py -v

Author

Courtney Rosenthal <cr@crosenthal.com>

License

This is free and unencumbered software released into the public domain.

See LICENSE for details.