"inotifywait -e close_write" 即使尾部显示换行也不触发

"inotifywait -e close_write" not triggering even when tail shows new lines

我有一个脚本:

nohup tail -f /somefile >> /soemeotherfile.dat &
nohup while inotifywait -e close_write /someotherfile.dat; do ./script.sh; done &

但似乎 script.sh 从未被激活,尽管输入每 5 分钟到达 /somefile 的尾部。我上面的脚本有什么问题?

来自 inotifywait 文档:

  • close_write

    A watched file or a file within a watched directory was closed, after being opened in writeable mode. This does not necessarily imply the file was written to.

close_write 仅在文件 关闭.

时触发
tail -f /somefile >> /soemeotherfile.dat

...继续追加到 someotherfile.dat。它不会在每次写入后关闭它。

您可能想要 modify 活动。