Using the Inotify-tools Monitor file directory

Source: Internet
Author: User
Tags inotify

Logging files and directory access is helpful for tracking changes to files and directories

Install Inotify-tools

1, download wget--no-check-certificate http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz 2, Environment Preinstallation Yum Install GCC 3, compiling tar zxf inotify-tools-3.14.tar.gz cd inotify-tools-3.14./configure make make Install

4. Use

Path=/tmp
#将目录或文件路径作为脚本参数
Inotifywait-m-r-e create,move,delete $path-Q

The output sample is as follows:
$/watchdir.sh.
./CREATE New
./Moved_from New
./Moved_to News
./DELETE News

The above script record is given the creation, movement, and deletion of files or directories in the path. Option-M indicates that you want to continue monitoring
Change, rather than exiting after the event occurs. -R allows the use of recursive monitoring of directories (ignoring symbolic links). -E designation
List of events that need to be monitored. -Q is used to reduce redundant information and only print out the required information. Command output can be redirected
to the log file.


Reference parameters:

Access (access) Read files
Modified (Modify) file contents modified
Property (attrib) file metadata is modified
Move moving file actions
Creating (Create) generating new files
Open (open) file operation
Closes (close) closes a file operation
Deleting file (delete)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.