How to monitor a complete directory tree for changes in Linux?

后端 未结 8 2062

How can I monitor a whole directory tree for changes in Linux (ext3 file system)?

Currently the directory contains about half a million files

8条回答
  •  日久生厌
    2020-12-02 10:25

    I've done something similar using the inotifywait tool:

    #!/bin/bash
    while true; do
    
    inotifywait -e modify,create,delete -r /path/to/your/dir && \
    
    
    done
    

    This will setup recursive directory watches on the entire tree and allow you to execute a command when something changes. If you just want to view the changes, you can add the -m flag to put it into monitor mode.

提交回复
热议问题