Skip to main content

inotify_service can be used to build a Linux service similar to the outdated incron.

It’s based on the (simple and efficient) python asyncinotify package.

We (Majerti) use it in production with a low load. We don’t have any feedback on performance to provide.

Install

apt-get install python3-venv
python3 -m venv /usr/local/inotify_service_venv
source /usr/local/inotify_service_venv/bin/activate
pip install inotify_service

Setup

You can download a suitable log.conf sample file on the github page :

https://github.com/majerteam/inotify_service/

mkdir -p /etc/inotify_service/conf.d
cp log.conf /etc/inotify_service/

Add yaml configuration files for the directories you want to watch.

Each yaml file can contain one or more configurations placed into a yaml list

- script: "sleep 2 | echo {path} > /tmp/titi.log"
  directory: "/tmp"
  pattern: "[a-z0-9_]+\\.pdf$"
  events:
    - "CLOSE_WRITE"
    - "MOVED_TO"

- script: "echo {path}"
  directory: "/home/gas/tmp/"
  events:
    - "CLOSE_WRITE"

Mandatory parameters:

script : The command to launch, the following parameters are passed

  • path : The absolute path on disk

  • filename: The name of the file

  • name : The event name (CLOSE_WRITE …)

directory : The directory to watch

events : List of events that should fire the script

Optionnal parameters:

pattern : A regexp pattern used to match the file names that can be managed

Systemd Service Setup

If you used the same directories as here above you can just use the .service file that you can download in the github repository.

https://github.com/majerteam/inotify_service/

cp inotify_service.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable inotify_service.service
systemctl start inotify_service.service
systemctl status inotify_service.service  # Default configuration should print the directories that are watched

Metadata

Release files for inotify-service 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inotify-service 1.0.2
File Size Uploaded
inotify_service-1.0.2.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for inotify-service 1.0.2
File Interpreter ABI Platform
inotify_service-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.4 kB

Release files / inotify_service-1.0.2.tar.gz

Download URL inotify_service-1.0.2.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ec3287bfcf02255f50bf8a1d7aa0770c453868347e6340dcf99cc9eef0339047
BLAKE2b-256 checksum
How to use checksums
685a302d7b37b5a4cb96b1e3115a35f76c61cb431d36b7dec33f12cd983f1808
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.4

Release files / inotify_service-1.0.2-py3-none-any.whl

Download URL inotify_service-1.0.2-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a103b5523da3da28992897e325fcb0176d48188b9fa5c82e30d545c24a06a7ee
BLAKE2b-256 checksum
How to use checksums
9f6f78c572195d3b4d66fcc666c8f5057da9955eafa5825648d0848e1714d38b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.4

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page