`entr`: How is update ID'd? noatime troubles?

2019-07-24 01:02发布

问题:

I have a script regularly appending to a log file. When I use entr (discovered here) to monitor that log file, and I then touch the log, everything works fine, but when the script appends to the file, entr fails. This may be because I have noatime set in my fstab - but that only stops the updating of the access time not the modify time, so this confuses me.

I've checked and while atime is not updating, ctime (ls -lc) definitely is. Could entr really be depending on atime? I use noatime because I have an SSD. So what should I do? I just stumbled on lazytime. Would that solve the problem?

Since monitoring the log file was not working, I tried entr -cdr on the directory of files that are updated (a new file is created) at the same time as the log (the log is in a different directory). entr recognizes when the directory contents change, but the -r does not work. The entr process just ends, saying "entr: directory altered".

Any idea how to fix this or whether I should just go back to inotify, would be appreciated.

Edit: I have written it with inotify now, and the event reported when the log file is written to is, sensibly enough, "MODIFY."

回答1:

It turns out that entr does not respond to IN_MODIFY events, but only to these (in Linux):

IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF|IN_CREATE

Also, IN_ATTRIB, but only if the file-mode or inode numbers change.

In BSD/OSX, it's:

NOTE_DELETE|NOTE_WRITE|NOTE_RENAME|NOTE_TRUNCATE|NOTE_ATTRIB

Also, the option -r has no effect in the context of the -d option. It only works when entr is monitoring files.

See the developer's comments. Also, more info on entr.



标签: inotify ctime