“inotifywait -e close_write”即使当 tail 显示新行时也不会触发

问题描述 投票:0回答:1

我有一个脚本:

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

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

bash inotify
1个回答
3
投票

来自

inotifywait
文档:

  • close_write

    以可写模式打开监视的文件或监视目录中的文件后,该文件被关闭。这并不一定意味着该文件已被写入。

close_write
仅在文件关闭时触发(这通常是可取的:它减少了在处于半写入状态时尝试读取内容的机会)。


tail -f /somefile >> /soemeotherfile.dat

...不断追加到

someotherfile.dat
。每次写入后,它不会关闭它。

可能您想要

modify
事件。

© www.soinside.com 2019 - 2024. All rights reserved.