Answers:
该inotify
内核系统是你所需要的。
安装inotify-tools
:
sudo apt-get install inotify-tools
设置手表:
inotifywait /path/to/directory --recursive --monitor
坐回去看输出。
-m, --monitor
Instead of exiting after receiving a single event, execute
indefinitely. The default behaviour is to exit after the first
event occurs.
-r, --recursive
Watch all subdirectories of any directories passed as arguments.
Watches will be set up recursively to an unlimited depth. Sym‐
bolic links are not traversed. Newly created subdirectories
will also be watched.
您可以使用该--event
选项来监视特定事件,例如创建,修改等。
inotify-wait
正义” inotifywait
。他们必须更改名称才能删除连字符。
--events
不是过滤器,则必须使用--event
。例如,以下是用于监视创建/修改事件的命令行:
# inotifywait . --recursive --monitor --event CREATE --event MODIFY
然后我看到:
Setting up watches. Beware: since -r was given, this may take a while!
这是提要的格式:
[path] [event] [file]
例如
./.mozilla/firefox/b4ar08t6.default/ MODIFY cookies.sqlite-wal
./.mozilla/firefox/b4ar08t6.default/ MODIFY cookies.sqlite-wal
./.mozilla/firefox/b4ar08t6.default/ MODIFY cookies.sqlite-wal