13

How can I log all the events performed on a particular directory?

I want to log the entry of each directory modified within some time duration. I am using find . -type d -mmin -5 command.

In addition to this, I want to put more details, when any directory is moved to another place, I need to add the below log details, eg.,

directory "xyz" moved from "home/usr/xyz" => to "home/usr/documents/xyz"

1 Answer 1

11

If using Linux, you should try inotifywait command, it's designed to listen events on files or directories.

inotifywait -m -r /dir

You can use a while loop over that to filter the output.

Moreover, it's very light : no need to poll() every N seconds, that's all the magic.

See http://inotify-tools.sourceforge.net/

1
  • inotify is Linux specific but the question is not tagged Linux. Good solutions are going to be OS specific like this one though. Commented Oct 7, 2012 at 22:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.