自己調研了很多軟體,隻有這一個能夠實作監控檔案打開的狀态,很強大,提供的example也很詳細
github首頁:https://github.com/seb-m/pyinotify/wiki/Events-types
可以監控到這些狀态
-
: a file was accessedIN_ACCESS
-
: a metadata changedIN_ATTRIB
-
: an unwritable file was closedIN_CLOSE_NOWRITE
-
: a writable file was closedIN_CLOSE_WRITE
-
: a file/directory was created in watched directoryIN_CREATE
-
: a file/directory was deleted in watched directoryIN_DELETE
-
: a watched item itself was deletedIN_DELETE_SELF
-
: don't follow a symlink (since kernel 2.6.15)IN_DONT_FOLLOW
-
: raised when a watch is removed. Probably useless for you, prefer using instead relying onIN_IGNORED
IN_DELETE*
-
: always associated with an event triggered on a directory. The Event structure automatically provides this information via attributeIN_ISDIR
event.dir
-
: to update a mask without overwriting the previous value (since kernel 2.6.14). Useful when updating a watchIN_MASK_ADD
-
: a file was modifiedIN_MODIFY
-
: a watched item was moved, currently its full pathname destination can only be known if its source and destination directories were both watched. Otherwise, the file is still being watched but you cannot rely anymore on the given path attributeIN_MOVE_SELF
event.path
-
: a file/directory in a watched directory was moved from another specified watched directory. Can trace the full move of an item whenIN_MOVED_FROM
is available too, in this case if the moved item is itself watched, its path will be updated (seeIN_MOVED_TO
)IN_MOVE_SELF
-
: a file/directory was moved to another specified watched directory (seeIN_MOVED_TO
)IN_MOVE_FROM
-
: only watch the path if it is a directory (since kernel 2.6.15). Usable when callingIN_ONLYDIR
watch_manager.add_watch()
-
: a file was opened.IN_OPEN
-
: the event queue overflown. This event is not associated with any watch descriptorIN_Q_OVERFLOW
-
: when backing fs was unmounted. Notified to each watch of this fsIN_UNMOUNT