inotifywait
是一个 Linux 命令行工具,用于监控文件系统事件
inotify-tools
软件包。在 Debian 系统上,你可以使用以下命令安装:sudo apt-get update
sudo apt-get install inotify-tools
inotifywait
监控文件或目录。以下是一些基本用法示例:inotifywait -m /path/to/file -e modify,attrib,close_write,move,create,delete
inotifywait -m /path/to/directory -e create,delete,modify,move
inotifywait -m /path/to/file1 /path/to/file2 /path/to/directory -e create,delete,modify,move
inotifywait -m /path/to/file -e create,delete
inotifywait -t 10 /path/to/file
inotifywait -m /path/to/file -e modify,attrib,close_write,move,create,delete --format '%w%f' --timefmt '%Y-%m-%d %H:%M:%S' | while read FILE
do
# 在这里执行你的自定义脚本
echo "File $FILE has been modified."
done
这些示例应该可以帮助你开始使用 inotifywait
。你可以根据需要调整参数以满足你的需求。更多关于 inotifywait
的信息和选项,请查阅其手册页(通过运行 man inotifywait
)。