Evi*_*ine 25
首先确保inotify-tools已安装.
然后像这样使用它们:
logOfChanges="/tmp/changes.log.csv" # Set your file name here.
# Lock and load
inotifywait -mrcq $DIR > "$logOfChanges" &
IN_PID=$$
# Do your stuff here
...
# Kill and analyze
kill $IN_PID
while read entry; do
# Split your CSV, but beware that file names may contain spaces too.
# Just look up how to parse CSV with bash. :)
path=...
event=...
... # Other stuff like time stamps?
# Depending on the event…
case "$event" in
SOME_EVENT) myHandlingCode path ;;
...
*) myDefaultHandlingCode path ;;
done < "$logOfChanges"
Run Code Online (Sandbox Code Playgroud)
或者,使用--format而不是-con inotifywait将是一个想法.
只是man inotifywait与man inotifywatch更多的相关信息.
您还可以incron使用它来调用处理脚本.
| 归档时间: |
|
| 查看次数: |
40498 次 |
| 最近记录: |