Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How to get a log of at what points in time a directory was modified?

Writer Olivia Zamora

In my present working directory, there is a subdirectory called modelled_data

I wish to get information on last few (may be 10) modifications of the subdirectory (including its subdirectories and files), specifically, the timestamps and types of modifications. Is it available via the terminals? Which commands or options should I try? ls -la gives a list of last modifications of all the subdirectories in the pwd. But I want last few modifications of a specific directory that I want to track.

2

1 Answer

There's no such logs. You can only see last modification time with stat command. That said, you can use inotifywait command from inotify-tools package. Example of its usage can be found on one of my other answers. Alternatively, you could use watchdog Python package. An example of usage is shown in watchdog's documentation. The output looks as so:

2018-11-10 21:32:45 - Modified directory: ./.config/Qlipper
2018-11-10 21:32:45 - Modified file: ./.config/Qlipper/qlipper.ini.lock
2018-11-10 21:32:45 - Created file: ./.config/Qlipper/qlipper.ini.yJ1483

You can start this as command python3 watchdog_example.py >> /var/log/my_directory.log & from /etc/rc.local and viola - you've got yourself a directory event logger that just works.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy