Run scripts responding to inotify events
Project description
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
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file inotify_service-1.0.1.tar.gz
.
File metadata
- Download URL: inotify_service-1.0.1.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88584582b0830c8e27f49fb91544572a87ba19df602ae994ea62a784cf95e160 |
|
MD5 | b2285804e3ae8f3da81cae90690273a2 |
|
BLAKE2b-256 | ef6799d0f6a742f790a57713c2e12968e2507684f341df36ce50aedfbec22cc6 |
File details
Details for the file inotify_service-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: inotify_service-1.0.1-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e6fc5041e6c2e8899f2da7e778feafe1433567e956ab6d0999d1a32eb44f120 |
|
MD5 | 79a6cf7c8474dc75e06be84b70fb9ee9 |
|
BLAKE2b-256 | d49db989e2a9a5c91318f7541d4088a89f8bb2ebf6dd731d7d4737e32cbce52e |