运行响应inotify事件的脚本
项目描述
inotify_service可用于构建类似过时的incron的Linux服务。
它基于(简单且高效的)python asyncinotify包。
我们在生产中使用它,负载很低。我们无法提供关于性能的反馈。
安装
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
设置
您可以在GitHub页面下载合适的log.conf示例文件
https://github.com/majerteam/inotify_service/
mkdir -p /etc/inotify_service/conf.d
cp log.conf /etc/inotify_service/
为要监视的目录添加yaml配置文件。
每个yaml文件可以包含一个或多个配置,放在yaml列表中
- 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"
必填参数
script : 要启动的命令,以下参数将被传递
path : 磁盘上的绝对路径
filename: 文件名
name : 事件名称(CLOSE_WRITE …)
directory : 要监视的目录
events : 应触发脚本的事件的列表
可选参数
pattern : 用于匹配可管理的文件名的正则表达式模式
Systemd服务设置
如果您使用了上面相同的目录,您可以直接使用GitHub存储库中可下载的.service文件。
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
项目详情
下载文件
下载您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。
源代码分发
inotify_service-1.0.2.tar.gz (17.4 kB 查看哈希值)
构建分发
inotify_service-1.0.2-py3-none-any.whl (19.0 kB 查看哈希值)
关闭
inotify_service-1.0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ec3287bfcf02255f50bf8a1d7aa0770c453868347e6340dcf99cc9eef0339047 |
|
MD5 | e5de17f9ecc9d7e730f207cec23b4b5c |
|
BLAKE2b-256 | 685a302d7b37b5a4cb96b1e3115a35f76c61cb431d36b7dec33f12cd983f1808 |
关闭
inotify_service-1.0.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a103b5523da3da28992897e325fcb0176d48188b9fa5c82e30d545c24a06a7ee |
|
MD5 | cfa899592c6a3c4e993dcd66329a5dc9 |
|
BLAKE2b-256 | 9f6f78c572195d3b4d66fcc666c8f5057da9955eafa5825648d0848e1714d38b |