I would like to know which files in my system I access most often, as a gauge of how important they are. I know the OS records the last time the file was accessed. Is there someone way to log in a text file each time the file is accessed, possibly on an hourly or daily timescale? I suspect I could use a chron task but I am not very familiar with using it. I would prefer an OS X solution.


2 Answers 2


You can use inotify. See example code below.



inotifywait --format '%:e %w%f' -e modify,delete,create \
    --exclude '^.+(jpe?g|gif|ico|png|svg|pdf|pptx?|swpx|swp)$' \
    -m -r "$src_path" | \
    while read watched_filename EVENT_NAMES; do
            case "$watched_filename" in
                            echo "$EVENT_NAMES has been modified"
                            echo "$EVENT_NAMES has been created"
                            echo "$EVENT_NAMES has been deleted"
                    *) echo "Unknown event, exiting";break

You can modify the script to do all kinds of things like send you an SMS on a MODIFY event.

  • 1
    inotify is for Linux, not OS/X Jun 9, 2016 at 18:27
  • @StéphaneChazelas that's a shame as I don't use OSX :D
    – likewhoa
    Jun 9, 2016 at 18:30

Here is a nice post about fswatch and inotify. I am not very familiar with fswatch however I use inotifywatch all the time and it sounds like what you're looking for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .