Linux systems monitor changes to files and folders under a directory

Source: Internet
Author: User
Tags inotify

Inotifywait is a tool that can monitor file changes in real-time, using the inotify mechanism in the Linux kernel to implement monitoring capabilities.

    1. View Kernel version
    2. [Email protected]oracle ~]# uname-r
    3. 2.6.32-220.el6.i686

    1. Installing Inotify-tools
    2. Yum Install-y Inotify-tools

Test monitoring/etc,inotifywait-m/etc

Use putty to connect to the server, open another terminal, with vim to edit the/etc/passwd, the other terminal display the corresponding monitoring information

inotifywait Command parameter description:the-M option indicates monitor, that is, turn on monitoringthe-r option indicates recursive monitoring, but it is slower, and if you monitor the/etc directory, the modified files in the subdirectories can be monitored.

The-e option specifies that the events to be monitored include: access, modify, attrib, close_write, Close_nowrite, close, open, moved_to, Moved_from, move, Move_self, create, delete, Delete_self, unmount.

    1. If the/etc/passwd file is modified, the event is recorded in the file/root/modify_passwd.txt
    2. Inotifywait-m/etc/passwd-e Modify >/root/modify_passwd.txt
If you do not add the parameter-E, the default is to monitor all events, in the daily operations, this tool can help you monitor the server on the important files and important directory changes.

Linux systems monitor changes to files and folders under a directory

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.