Ubuntu: How can I log the activity of a directory? [duplicate]



Question:

This question already has an answer here:

I need to know which files have been copied to or removed from a directory or folder such /dev or /mnt or any other directory.

How can I do that?


Solution:1

You could use inotifywait to monitor directories for files that have been accessed, deleted or moved.

Install inotify-tools

sudo apt-get update    sudo apt-get install inotify-tools    

Then run:

inotifywait -m -r /mnt     

The "-m" option monitors the directory and "-r" is recursive. Unless otherwise specified by "-e" option, all events will be displayed as defined in the inotifywait manpage. The events can be sent to a log file by using the "-o" option:

inotifywait -m -r -o /directory/logfile.txt /mnt  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »