当我在建一个rpm包管理服务器时,里面有个这样的要求,要求当有新的rpm存入指定目录时,自动执行一段脚本去对这个rpm包进行检测。
这里利用了inotify-tools的inotifywait的模块,里面有个事件处理的参数-e,见它的手册。
我的代码如下:
#/bin/bash
################################################################
# automatically run a script(action.sh) when the contents
# of a directory (${EVENTPATH}) changed.
# pls. install the inotify-tools-3.13-1.el4.rf.i386.rpm module
# before use this scripts
# Aborn Jiang (aborn.jiang@gmail.com)
# Sep.8, 2013
################################################################
EVENTPATH="."
MSG=".inotifymsg"
PATTERN=".rpm$" # only when the rpm files changed.
while inotifywait -e modify -e create -e delete -e moved_to -e moved_from \
${EVENTPATH} 1>${EVENTPATH}/$