In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article Xiaobian introduces in detail "how to install and use inotifywait commands in Linux" with detailed content, clear steps and proper handling of details. I hope that this article "how to install and use inotifywait commands in Linux" can help you solve your doubts.
Linux commonly used commands Inotify is a powerful, fine-grained, asynchronous file system monitoring mechanism that meets a variety of file monitoring needs. It can monitor file system access properties, read-write properties, permission properties, delete creation, movement and other operations, that is, it can monitor all changes in files.
Inotifywait Asynchronous File system Monitoring Mechanism
It is added that inotify-tools is a C library and a set of command line work to provide a simple interface to inotify under Linux. After inotify-tools is installed, you will get two commands: inotifywait and inotifywatch:
The inotifywait command can be used to collect information about file access, which is generally not included in Linux distributions and requires inotify-tools to be installed. This command also requires compiling inotify support into the Linux kernel. Fortunately, most Linux distributions have inotify enabled in the kernel.
The inotifywatch command is used to collect statistics about the file system being monitored, including how many times each inotify event occurs.
Before you start, you need to check whether the system kernel supports inotify:
Use the uname-r command to check the Linux kernel. If it is lower than 2.6.13, you will need to recompile the kernel to add inotify support.
Use the ll / proc/sys/fs/inotify command, whether there are the following three pieces of information output, if not indicates that it is not supported.
Ll / proc/sys/fs/inotify total 0-rw-r--r-- 1 root root 0 Jan 4 15:41 max_queued_events-rw-r--r-- 1 root root 0 Jan 4 15:41 max_user_instances-rw-r--r-- 1 root root 0 Jan 4 15:41 max_user_watches install inotify-tools # CentOS release 5.8 root root 64-bit: tar zxvf inotify-tools-3.14.tar.gz cd inotify-tools-3.14. / configure make Make installinotify related parameters inotify defines the following interface parameters Can be used to limit the size of kernel memory consumed by inotify. Because these parameters are memory parameters, they can be adjusted in real time according to the application requirements:
/ proc/sys/fs/inotify/max_queued_evnets represents the maximum number of event that can be queued in the inotify instance when inotify_init is called. Events beyond this value are discarded, but the IN_Q_OVERFLOW event is triggered.
/ proc/sys/fs/inotify/max_user_instances represents the upper limit of the number of inotify instatnces that can be created per real user id.
/ proc/sys/fs/inotify/max_user_watches represents the maximum number of directories that can be monitored per inotify instatnces. If the number of files being monitored is large, you need to increase the size of this value as appropriate.
Based on the above, it can be performed on either 32-bit or 64-bit systems:
Echo 104857600 > / proc/sys/fs/inotify/max_user_watches echo 'echo 104857600 > / proc/sys/fs/inotify/max_user_watches' > > / etc/rc.local if you encounter the following error:
Inotifywait: error while loading shared libraries: libinotifytools.so.0: cannot open shared object file: No such file or directory * * solution: * * 32-bit system: ln-s / usr/local/lib/libinotifytools.so.0 / usr/lib/libinotifytools.so.0 64-bit system: ln-s / usr/local/lib/libinotifytools.so.0 / usr/lib64/libinotifytools.so.0inotifywait command use #! / bin/bash # filename watchdir.sh path=$1 / usr/local/bin/inotifywait -mrq-- timefmt'% damp% mUnip% y modify% HGV% M'-- format'% T% w% f'- e modify Delete,create Attrib $path executive output:. / watchdir.sh / data/wsdata/tools/ 04Accord 01Accord 13Univ 34 / data/wsdata/tools/ .j.jsp.swp 04Unip 04Unip 01Univ 16purl 34 / data/wsdata/tools/ .j.jsp.swx 04Unip 01Univ 13Univ 34 / data/wsdata/tools/ .j.jsp.swx 04Unip 04Unix 04Unimax 16purr 34 / data/wsdata/tools/ .j.jsp.swp 04Univer 011316 : 34 / data/wsdata/tools/ .j.jsp.swp 04/01/13/16:34 / data/wsdata/tools/ .j.jsp.swp 04/01/13/16:35 / data/wsdata/tools/ 4913 04/01/13/16:35 / data/wsdata/tools/ 4913 04 / 01UX 13Univ 35 / data/wsdata/tools/ 4913 04GUBE 01UX 13UR 16JUR 35 / data/wsdata/tools/ j.jsp 04UniGER 01RX 13RX 16JUR 35 / data/wsdata/tools/ j.jsp 04GUBE 01RX 13RX 16JUR 35 / data/wsdata/tools/ j.jsp 04GUBE 01CHARE 16JUR 35 / data/wsdata/tools/ j.jsp04According to the-m command parameter-m is to monitor the changes continuously.
-r monitors directories using recursion.
-Q reduces redundant information and prints out only the information you need.
-e specifies the list of events to monitor.
-- timefmt is the output format for the specified time.
-- format specifies the details of the file changes.
Listenable events describe access access and read files. Modify is modified and the file content is modified. Attrib property, the file metadata is modified. Move move, move the file. Create create, generate new file open open, open the file. Close closes and closes the file. The delete is deleted and the file is deleted. After reading this, the article "how to install and use inotifywait commands in Linux" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.