inotify

You can watch realtime operations happing in directory using inotifywatch and inotifywait command

Install inotify tool

sudo apt install inotify-tools

Create directory

mkdir -p /tmp/test

Watch action

inotifywatch -v -e modify,create,delete /tmp/test

Ctrl + C

#Then check statistics

Real time watch action

inotifywait -m -e modify,create,delete /tmp/test/

Now try to create modify and delete the file

touch /tmp/test/file1.txt
echo "Hello" > /tmp/test/file1.txt
rm /tmp/test/file1.txt

Ctrl + C
Left terminal to watch activities and right one to run commands

To monitor multiple paths at a time run following commands

inotifywatch -e access,modify /home/user/myfolder /home/user/another_folder /home/user/myfile.txt
OR
inotifywait -m -e access,modify /home/user/myfolder /home/user/another_folder /home/user/myfile.txt

Leave a Reply

Your email address will not be published. Required fields are marked *