小编mib*_*456的帖子

使用 inotify 监控目录但不能 100% 工作

我编写了一个 bash 脚本来监视特定目录/root/secondfolder/

#!/bin/sh

while inotifywait -mr -e close_write "/root/secondfolder/"
do
    echo "close_write"
done
Run Code Online (Sandbox Code Playgroud)

当我创建一个名为fourth.txt/root/secondfolder/和写的东西给它,保存并关闭它,它输出以下内容:

/root/secondfolder/ CLOSE_WRITE,CLOSE fourth.txt
Run Code Online (Sandbox Code Playgroud)

但是,它不会回显“close_write”。这是为什么?

shell shell-script inotify

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

inotify ×1

shell ×1

shell-script ×1