我试图使用inotifywait来检测文件或文件夹每次实时移动到文件夹中(例如/ root中的/ root)
我尝试了这个,它确实检测了文件夹和文件,但这是针对创建的文件,我希望它用于移动的文件/文件夹。
inotifywait --monitor --format %f --event create /root
然后我使用它,但使用它只能看到文件夹移入时,当我移入文件时没有显示任何内容...... :(
inotifywait --monitor --format %f --event moved_to /root
知道发生了什么事吗?
PS,我使用Linux,Debian 5(Lenny)。
答案 0 :(得分:2)
您可以使用inotify指定许多事件。在你的情况下,你似乎需要这样的东西:
inotifywait --monitor --format %f --event move --event create /root
它应该有效。如果您需要更多内容,请仔细阅读手册页:
-e <event>, --event <event>
Listen for specific event(s) only.
The events which can be listened for are listed in the EVENTS section.
This option can be specified more than once.
If omitted, all events are listened for.
[...]
EVENTS
The following events are valid for use with the -e option:
[...]
move A file or directory was moved from or to a watched directory.
Note that this is actually implemented simply by listening for both moved_to
and moved_from, hence all close events received will be output as one or both
of these, not MOVE.
create A file or directory was created within a watched directory.
它适用于移动/触摸。希望它有所帮助...